Hi Mike, I ran into the same problem and the easiest way I came up with was just by forcing the window to be destroyed every time the script ran. Just like you would do in the old days with mel :)
if pm.window( 'testWindow', query = True, exists = True ) : pm.deleteUI( 'testWindow' ) So add those lines to your script and that deletes the old window. Jan 2013/7/10 Mike Malinowski (LIONHEAD) <mich...@microsoft.com> > Hey All,**** > > ** ** > > I’m getting an issue whereby my PySide windows are not being properly > destroyed when they’re closed.**** > > ** ** > > ** ** > > <code>**** > > import pymel.core as pm**** > > ** ** > > from PySide.QtCore import ***** > > from PySide.QtGui import ***** > > import shiboken**** > > import maya.OpenMayaUI as mui**** > > ** ** > > def getMayaWindow():**** > > ptr = mui.MQtUtil.mainWindow()**** > > return shiboken.wrapInstance(long(ptr), QWidget)**** > > ** ** > > class testWindow( QMainWindow ) :**** > > **** > > def __init__ ( self, parent=getMayaWindow() ) : **** > > QMainWindow.__init__( self, parent=parent )**** > > self.setObjectName("testWindow")**** > > self.layout = QHBoxLayout()**** > > self.label = QLabel("test panel")**** > > self.layout.addWidget(self.label)**** > > self.setLayout(self.layout)**** > > **** > > window = testWindow()**** > > window.show()**** > > ** ** > > </code>**** > > ** ** > > Run the code above a couple of times, and close the window each time. Now > run this :**** > > ** ** > > <code>**** > > from PySide.QtCore import ***** > > from PySide.QtGui import ***** > > import shiboken**** > > ** ** > > import pymel.core as pm**** > > import maya.OpenMayaUI as mui**** > > ** ** > > def getMayaWindow():**** > > ptr = mui.MQtUtil.mainWindow()**** > > return shiboken.wrapInstance(long(ptr), QWidget)**** > > **** > > for child in getMayaWindow().children() :**** > > **** > > objName = child.objectName()**** > > if objName == "" : print "->"+str(child)**** > > else : print "->" + objName**** > > print len(getMayaWindow().children())**** > > </code>**** > > ** ** > > Notice that there are multiple instances of the window still there. The > only way I can currently clean it up is to add this to the QMainWindow > class :**** > > ** ** > > <code>**** > > def closeEvent( self, event ) :**** > > QMainWindow.closeEvent( self, event )**** > > shiboken.delete(self)**** > > </code>**** > > ** ** > > However, some of my dynamic UI’s cause a crash with this override, and it > feels a little heavy handed to have to override the closeEvent. Has anyone > else hit this issue?**** > > ** ** > > Mike**** > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to python_inside_maya+unsubscr...@googlegroups.com. > To post to this group, send email to python_inside_maya@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To post to this group, send email to python_inside_maya@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.