[PyQt] C++ and embedded python, how to share gui thread?

Michael Olberg michael.olberg at chalmers.se
Fri May 25 07:30:44 BST 2007


Just a follow-up: on a recently installed Debian etch my old problem is
back, i.e. a python script trying to open a Qt dialog hangs the C++ Qt
application where python is embedded. 

The exactly same program works fine in Ubuntu feisty as reported
earlier. The application was originally developed under Debian sarge,
where it also worked, but I had to stick to a particular version of
python-qt.

/Michael

On Thu, 2007-05-17 at 12:19 +0200, Michael Olberg wrote:
> I have just installed Ubuntu Feisty on my laptop and everything appears to work 
> fine again. So consider the problem solved for the moment ;-).
> 
> thanks for all advice I received,
> Michael
> 
> Patrick Stinson wrote:
> > there is only one QApplication. Even in apps where you are writing a
> > graphical plugin that will be used in a native event loop, you have to
> > manage one QApplication instance. So, if your C++ app created a
> > QApplication then you don't have to worry about it just create the
> > PyQt widgets at will. This will all work the best if the qt lib you
> > are using is a shared library or dll, because you don't want to link
> > it in twice; once with the C++ app and once with the PyQt4 module.
> > 
> > I Hope that helps a little. I have more info on how I did the same thing 
> > here:
> > 
> > http://www.patrickkidd.com/pk/trac/wiki/EmbeddedPythonWidgets
> > 
> > On 5/16/07, Michael Olberg <michael.olberg at chalmers.se> wrote:
> >> Dear all,
> >>
> >> I have a scientific application programmed in C++ with the Qt widget 
> >> set. I have
> >> embedded a Python interpreter to allow me to control the application via
> >> scripts. I can even import the python-qt bindings in those scripts and 
> >> create
> >> graphical dialogs. So at present everything works(!) as expected.
> >>
> >> However, this works with an old setup of Debian sarge and the
> >> python2.3-qt3_3.11-4_i386.deb package. A number of upgrades have 
> >> happened since
> >> then, with python, with qt, and even with Debian. With newer versions
> >> non-graphical scripts still work, but any attempt to open Qt dialogs 
> >> from the
> >> embedded python interpreter hangs the application.
> >>
> >> It appears to me that this has to do with how later versions of the 
> >> python-qt
> >> package access the main Qt GUI thread, which in my case is already 
> >> started by
> >> the underlying C++ application.
> >>
> >> I wonder if this is documented somewhere, with an example on how to 
> >> start the
> >> python interpreter so that the C++ and python can share the same Qt 
> >> GUI? I'd
> >> very much like to upgrade my system without breaking this application, 
> >> which I
> >> use for daily work.
> >>
> >> any info appreciated,
> >> Michael
> >> _______________________________________________
> >> PyQt mailing list    PyQt at riverbankcomputing.com
> >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> >>
> > 
> > 
> 



More information about the PyQt mailing list