[PyQt] DOUBTT
Amey Patil
amey.patil at sjsu.edu
Wed Jul 23 22:59:48 BST 2014
Hi,
I am at the basic level in using sip wrapper in python. I have written a
small library in c++ and wrapping it in sip for execution in Python.
Copy pasting my entire files for better understanding. Also pasting the
output from the terminal, the behaviour i am getting is completely
unexpected, can you please look into it...
*word.h:*
class Word
{
public:
int integer;
const char *name;
Word();
void set_name(const char *a);
void reset_name();
const char *get_name();
};
*word.cpp:*
#include <iostream>
#include "word.h"
using namespace std;
Word::Word(){
name = "PyQt";
}
void Word::set_name(const char *a){
cout << "parameter passed to set_name is " << a << endl;
cout << "name before set_name is " << name << endl;
name = a;
cout << "name after set_name is " << name << endl;
}
void Word::reset_name(){
cout << "name before reset_name is " << name << endl;
const char *x = "Epics";
name = x;
cout << "name after reset_name is " << name << endl;
}
const char *Word::get_name(){
cout << "name before get_name is " << name << endl;
return name;
}
*word.sip:*
%Module word
class Word
{
%TypeHeaderCode
#include <word.h>
%End
public:
int integer;
const char *name;
Word();
void set_name(const char *a);
void reset_name();
const char *get_name();
};
*Output in Python (Terminal):*
>>> import word
>>> w = word.Word()
>>> w.get_name()
name before get_name is PyQt
'PyQt'
>>> w.set_name("Amey")
parameter passed to set_name is Amey
name before set_name is PyQt
name after set_name is Amey
>>> w.get_name()
name before get_name is
''
>>> w.reset_name()
name before reset_name is <stdin>
name after reset_name is Epics
>>> w.get_name()
name before get_name is Epics
'Epics'
PROBLEMS:
1. It won't print the output when i call get_name() after calling set_name()
.
2. As you can see in the output, I am editing nothing between the
highlighted lines, still the output shows nothing in one while <stdin> in
other.
Please tell me what's wrong.
Looking forward for your reply,
Sincere Regards,
Amey Patil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140723/ab529bcb/attachment-0001.html>
More information about the PyQt
mailing list