[PyQt] convert windows app to PyQt Widget
Hans-Peter Jansen
hpj at urpla.net
Mon Nov 29 17:38:23 GMT 2010
On Monday 29 November 2010, 16:31:17 M Chauhan wrote:
> Hello all,
>
> I have been trying to convert an app launched by windows (for ex.
> calc) into a QT Widget. In docs, I found a "find()" command which
> should do that. (
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.ht
>ml#find )
>
> But "find" returns a None.
>
> Below you will find an example code for calculator app. May be I am
> not doing something right.
> Any pointers please? (I am using : PyQT 4.7.1, Windows XP, Python
> 2.6.4)
>
> Ex code:
>
> import os , time, win32gui
> from subprocess import Popen
> from PyQt4 import QtGui
> root_dir = os.environ.get("SystemRoot",r"C:\WINDOWS")
> calc = r'%s\System32\calc.exe' % root_dir
> Popen(calc)
> time.sleep(1)
> #Get window handle of calc window
> calc_hwnd = win32gui.FindWindow(None, "Calculator")
> #Creat QT Application
> a = QtGui.QApplication([])
> mainwin = QtGui.QMainWindow()
> #Set QT mainwindow as parent of calc window
> win32gui.SetParent(calc_hwnd, int(mainwin.winId()))
> mainwin.showMaximized()
> mainwin.show()
> #Convert calc into QT widget
> wgt = mainwin.find(calc_hwnd)
> #XXX: following print gives "None"
> *print type(wgt)*
> a.exec_()
I wouldn't expect something like this to have a _chance_ to work
properly. You might get away with some Active X controls, but embedding
arbitrary windows is possible with X11 only (AFAIK).
Pete
More information about the PyQt
mailing list