[PyQt] embedding a windows application in a qwidget

victor noagbodjivictor at gmail.com
Sun Aug 1 19:19:59 BST 2010


hello group,

came across a nice feature in gtk that embeds applications in a gtk widget
using the xembed protocol. i looked around to see if (py)qt has
similars. windows users are not so fortunate however.

i learned about a SetParent win32 api call (
http://msdn.microsoft.com/en-us/library/ms633541(VS.85).aspx). and that qt
can return a native window id. so i came up with the following code (which
does not work, mind you :) )

anyone who knows better has an idea how it can be accomplished?

thanks a lot in advance

=================


import sys
import ctypes
import subprocess

from PyQt4 import QtGui


if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    process = subprocess.Popen(['c:/vim/vim72/gvim.exe'])

    # this call is to get the process window handle
    SYNCHRONIZE = 0x00100000
    handle = ctypes.windll.kernel32.OpenProcess(
        SYNCHRONIZE, False, process.pid
    )

    w = QtGui.QWidget()
    wid = w.winId()     # this one turns out to be an void* c type, might be
the culprit
    w.show()

    ctypes.windll.user32.SetParent(handle, int(wid))

    sys.exit(app.exec_())

-- 
victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100801/76e62904/attachment.html>


More information about the PyQt mailing list