From pykde Wed Sep 27 23:12:41 2006 From: Jim Bublitz Date: Wed, 27 Sep 2006 23:12:41 +0000 To: pykde Subject: Re: [PyKDE] Using QXEmbed Message-Id: <200609271612.41826.jbublitz () nwinternet ! com> X-MARC-Message: https://marc.info/?l=pykde&m=115939960120639 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 _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde