[PyKDE] Using QXEmbed
Adrien Vermeulen
adrien.vermeulen at gmail.com
Thu Sep 28 15:22:23 BST 2006
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.
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.
Is there someone who understands this?
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...
AdrienV
2006/9/28, Jim Bublitz <jbublitz at nwinternet.com>:
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060928/af198b1d/attachment.html
More information about the PyQt
mailing list