[PyKDE] embedding PyQt in a c++ app

Christoph Wiedemann wiedeman at gmx.net
Thu Jul 29 17:23:00 BST 2004


Hello,

i have problems to embed PyQt in a c++ application. Since the application
uses threads and multiple python interpreters, i must ensure that the
correct thread state is set and the GIL is locked, whenever the python API
is used. I do that with the

  PyEval_RestoreThread(threadState);

and

  PyEval_SaveThread();

methods. This works fine, as long as i don't use widgets created with PyQt,
because there are many "callbacks" (virtual methods), e.g. mousePressEvent,
which are called directly from PyQt. 

Is there any way to force PyQt to acquire the GIL before those virtual
methods are called?

Hmm, this wouldn't solve the issue with multiple interpreters; each
interpreter has its own thread state, which must be restored before using
the API. 

Maybe someone on this list has some ideas how to cope with this situation ?

Thanks,
Christoph




More information about the PyQt mailing list