[PyKDE] Using QXEmbed

Jim Bublitz jbublitz at nwinternet.com
Thu Sep 28 00:12:41 BST 2006


On Wednesday 27 September 2006 14:35, Adrien Vermeulen wrote:
> I am currently writing a frontend application for snes9x (a command line
> snes emulator) with pyqt3/pykde. I first wanted to write it with pyqt4 but
> because QX11EmbedContainer is missing I switched to pykde and its QXEmbed
> class.
> But that's not the problem. It is that the application always reacts
> differently each time I start snes9x (loading a rom with it : a snes game
> file) with a QProcess and then try to embed it. Sometimes it isn't embeded
> at all and stay in a X window, sometimes it seems to be embeded (sound
> works but nothing more is displayed in the pykde window) and minimizing the
> pykde application make snes9x appear in an external X window, and sometimes
> it simply works.
> The two questions are why and what can I do to improve my code and make it
> stable?
>
> Thank you in advance, AdrienV
>
> PS: my script is joined to this email.

The example provided with PyKDE has the same problem - KWrite will always 
embed, KCalc sometimes, and Konqueror never. The problem is that the window 
ID (WId - returned from winobj.win) isn't available until the app finishes 
initializing, so it can't be embedded until then. KWrite inits quickly, KCalc 
is slower, and Konqueror takes a while longer to load.

Increasing the QTimer interval fixes the problem - I increased it from 2000 to 
5000 (5 seconds) for the next PyKDE release, and that always works (at least 
on my computers). You need to find a value that works for you application, or 
else loop until winobj.win is not None, probably with some kind of watchdog 
timer to prevent an infinite loop if the program being embedded crashes or 
otherwise doesn't load.

Jim




More information about the PyQt mailing list