Query regarding PythonQt

Shankar Narayana shank.nasa at gmail.com
Fri Jun 27 14:41:53 EDT 2008


Hi,
 I am newbie to PythonQt. I wanted to access the Qt objects created in C++
using Python and update things. I had a look at this URL "
http://doc.trolltech.com/qq/qq23-pythonqt.html#decoratorsandcwrappers" which
talks about using PythonQt for the same.
  I followed the instructions given in the example. I created my cpp file
and .py file and could make them working.
  But once after the first time after .pyc file is created, my program no
longer executes. It is giving me a segmentation fault. If I remove my .pyc
file and run the program, things work fine.

My cpp file
#include <QApplication>
#include <QTextEdit>
#include "PythonQt.h"
int main(int argc, char* argv[])
{
    QApplication app(argc,argv);
    QTextEdit *welcomemsg = new QTextEdit("Hi whatsup");
    PythonQt::init();
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("welcomemsg",welcomemsg);  // Check with different
names
    mainModule.evalFile("Pyscript.py");
    mainModule.removeVariable("welcomemsg");
    PythonQt::cleanup();
    return app.exec();
}

My Python file  (Pyscript.py)

from PythonQt import *
#append the text to the existing text edit
welcomemsg.append("Hurray I did it")
welcomemsg.show()

Can somebody help me what makes this not to run once Python interpreter
works on the Python file and creates a .pyc file ?


Regards,
Shankar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080627/5deb9077/attachment.html>


More information about the Python-list mailing list