[PyQt] win32gui.SetParent method with pyqt

Matteo Boscolo matteo.boscolo at boscolini.eu
Tue May 3 20:39:31 BST 2011


hi all,
I solve the problem in this way:

this is the definition of the pyqt dialog:
..
...
class ClientInterface(QDialog):
     '''
     Class that manage all the interface actions
     '''
     def __init__(self,hwid=False):
         '''
             Dialog Constructor
         '''
         parent=None
#
         QDialog.__init__(self,parent)
         self.setParent=False

     def setParentTD(self,objectDialog):
         try:
             if self.setParent!=True:
                 main_app = 'thinkdesign'
                 calc_hwnd = win32gui.FindWindow(None, main_app)
                 win32gui.SetParent(objectDialog.winId(),calc_hwnd)
                 self.setParent=True
         except:
             print "error on set parent"

    def showWarning(self,message):
         """
             show a warning message
         """
         self.setParentTD(self)
         self._message("warning", message)

    def _message(self,type,message):
         self.setParentTD(self)
         msg=QMessageBox(self)
         msg.setText(message)
         if type=="warning":
             msg.setIcon(QMessageBox.Warning)
         elif type=="error":
             msg.setIcon(QMessageBox.Critical)
         else:
             msg.setIcon(QMessageBox.Information)
         msg.exec_()
..
....
...

the ClientInterface in this case is an hidden object that wrap around 
the mfc main application.

Hope that helps someone ..


Regards,
Matteo

Il 03/05/2011 12:29, Matteo Boscolo ha scritto:
> Hi All,
> I got a win mfc application and I have extended it win win32com using 
> the pyqt as windows manager..
>
> all work well but the two windows (pyqt diaolog and mfc application ) 
> are in the some level but I need that the pyqt dialog is modal to the 
> mfc application ..
> I use this function to set the parent .
>
>   def setParentTD(self,objectDialog):
>         try:
>             main_app = 'thinkdesign'
>             calc_hwnd = win32gui.FindWindow(None, main_app)
>             print "calc_hwnd ",str(calc_hwnd )
>             print "self.winId ",objectDialog.winId()
>             win32gui.SetParent(objectDialog.winId(),calc_hwnd)
>         except:
>             print "error on set parent"
> where objectDialog is the pyqt dialog ...
>
> in this way the pyqt dialog disappear ..
>
> any idea how to do such a think ..??
>
> regards,
> Matteo
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
>
> -----
> Nessun virus nel messaggio.
> Controllato da AVG - www.avg.com
> Versione: 10.0.1209 / Database dei virus: 1500/3611 -  Data di 
> rilascio: 02/05/2011
>
>



More information about the PyQt mailing list