[PyQt] convert windows app to PyQt Widget
M Chauhan
mrch81 at gmail.com
Mon Nov 29 15:31:17 GMT 2010
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.html#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_()
Thanks and wishes,
Mru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101129/de0d3ce4/attachment.html>
More information about the PyQt
mailing list