[PyKDE] Re: embedding python widgets in C++ app

Phil Thompson phil at riverbankcomputing.co.uk
Fri Jan 26 09:44:51 GMT 2007


On Friday 26 January 2007 7:40 am, Patrick Stinson wrote:
> My mail config was a little messed up, so I'm trying to manually
> continue this thread.
>
> David: I've copied your code almost exactly, and I'm getting seg
> faults in Py_CallObject after copying your call_function() from the
> web. The pyDict and callable pointers are both valid... any ideas?
>
> Phil: Why does PyQt4.QtCore still not exist after the following code:
>
> extern "C"
> {
>   void initsip();
>   void initQtCore();
>   void initQtGui();
> }
>
> int main()
> {
>
>       struct _inittab builtin_modules[] = {
> 	{ "sip", initsip },
> 	{ "PyQt4.QtCore", initQtCore },
> 	{ "PyQt4.QtGui", initQtGui },
> 	{ NULL, NULL }
>       };
>
>       PyImport_ExtendInittab(builtin_modules);
>
>       printf("Initializing Python...");
>       Py_Initialize();
>       printf(" done.\n");
>
>       PyRun_SimpleString("import PyQt4.QtCore");
>
> }
>
> >>> "no module PyQt4.QtCore"

I assume that "import sip" works.

I would try something like "import sys; print sys.builtin_module_names" after 
the QtCore import to see what's actually there and what it is called. The 
fact that QtCore is part of a package may affect things.

Phil




More information about the PyQt mailing list