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

Phil Thompson phil at riverbankcomputing.co.uk
Sat Jan 27 10:58:11 GMT 2007


On Saturday 27 January 2007 10:33 am, Miguel Lobo wrote:
> > > ok, removing all instances of "PyQt4." from the cpp, and without
> > > modifying the sip files, I get this error for
> > > PyRun_SimpleString("import QtCore; print QtCore"):
> > >
> > > SystemError: _PyImport_FixupExtension: module QtCore not loaded
> > >
> > > and this error for PyRun_SimpleString("import QtGui; print QtGui"):
> > >
> > > ImportError: No module named PyQt4.QtCore
> > >
> > > After changing the module names in the sip files and recompiling the
> > > PyQt4 static libs it seems to work. I That means that the PyQt4
> > > package definately gets in the way.
> > >
> > > So this looks fine except everyone on our team has to do this
> > > everytime they download a new version. Ideas?
> >
> > So if I added a command line flag to SIP to ignore all but the last part
> > of a %Module directive, and tied that flag to the -k flag of PyQt's
> > configure.py, then it should work Ok?
>
> I run into the exact same problem as Patrick a couple of days ago.  I have
> submitted a patch to the Python team that allows "import PyQt4.QtCore" to
> work.  You can find the patch here:
> http://sourceforge.net/tracker/?func=detail&aid=1644818&group_id=5470&atid=
>305470
>
> I would vote against renaming PyQt4.QtCore to QtCore for the statically
> linked PyQt because then it would mean that you need "from PyQt4 import
> QtCore" if you have linked PyQt4 dynamically and "import QtCore" if you
> have linked it statically.  I use static PyQt4 in Windows (for ease of
> deployment), but in Linux I use the dynamic version, so this solution would
> be inconvenient for me.

That's a good point - I was only thinking of the embedded case where you often 
do the imports separately.

If your patch doesn't get accepted then I'm happy to host it. As you are 
building a bespoke interpreter anyway it's no great problem to have to apply 
a patch as well.

Phil




More information about the PyQt mailing list