[PyQt] convert windows app to PyQt Widget

M Chauhan mrch81 at gmail.com
Wed Dec 1 10:26:52 GMT 2010


Thanks Pete,

I guess, like you said, I should avoid this on windows. However I will try
it on X11 to see if it works fine.

Regards,
Mrugesh.

On 29 November 2010 18:38, Hans-Peter Jansen <hpj at urpla.net> wrote:

> 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
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101201/fb0fd0c5/attachment-0001.html>


More information about the PyQt mailing list