Thank you very much for your answer. I made some tests and it appears that the problem doen't come from the KWin WinId. In fact this value is well set even 500 ms after starting the QProcess (snes9x is a light process). Even with a
QTimer.SingleShot of more than 5s it didn't work every time, only some time and I still don't know why.<br>But something funny is that I found a strange solution to this embeding problem. I realised that embeding works every time I minimize snes9x external window before. So I put "
KWin.iconifyWindow(winobj.win, False)" just before "QXEmbed.embed(winobj.win)" and now it works with a 500 ms QTimer.SingleShot.<br><br>Is there someone who understands this?<br><br>Another thing to know is that snes9x X window has always a pid = 0, that's why the method used in the example to find the right window doesn't work, in fact the pid returned by the QProcess is snes9x's command pid, not the X window...
<br><br>AdrienV<br><br><div><span class="gmail_quote">2006/9/28, Jim Bublitz <<a href="mailto:jbublitz@nwinternet.com">jbublitz@nwinternet.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wednesday 27 September 2006 14:35, Adrien Vermeulen wrote:<br>> I am currently writing a frontend application for snes9x (a command line<br>> snes emulator) with pyqt3/pykde. I first wanted to write it with pyqt4 but
<br>> because QX11EmbedContainer is missing I switched to pykde and its QXEmbed<br>> class.<br>> But that's not the problem. It is that the application always reacts<br>> differently each time I start snes9x (loading a rom with it : a snes game
<br>> file) with a QProcess and then try to embed it. Sometimes it isn't embeded<br>> at all and stay in a X window, sometimes it seems to be embeded (sound<br>> works but nothing more is displayed in the pykde window) and minimizing the
<br>> pykde application make snes9x appear in an external X window, and sometimes<br>> it simply works.<br>> The two questions are why and what can I do to improve my code and make it<br>> stable?<br>><br>> Thank you in advance, AdrienV
<br>><br>> PS: my script is joined to this email.<br><br>The example provided with PyKDE has the same problem - KWrite will always<br>embed, KCalc sometimes, and Konqueror never. The problem is that the window<br>ID (WId - returned from
winobj.win) isn't available until the app finishes<br>initializing, so it can't be embedded until then. KWrite inits quickly, KCalc<br>is slower, and Konqueror takes a while longer to load.<br><br>Increasing the QTimer interval fixes the problem - I increased it from 2000 to
<br>5000 (5 seconds) for the next PyKDE release, and that always works (at least<br>on my computers). You need to find a value that works for you application, or<br>else loop until winobj.win is not None, probably with some kind of watchdog
<br>timer to prevent an infinite loop if the program being embedded crashes or<br>otherwise doesn't load.<br><br>Jim<br></blockquote></div><br>