I’ve got a tool that’s created with QtDesigner, comverted to a .py file and then loaded by inheriting from this .py file. It has also been made dockable by use of Pymel’s dockcontrol. Relevant code:
def OnClose():
print "Close Event fired!"
class MainWindow(QtGui.QMainWindow, Exportsets_UI.Ui_ExportSets):
def __init__(self, parent=qtUtils.getAppWindow()):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.setObjectName('ExportSets_MainWindow')
if pm.dockControl( 'ExportSets_Dock', q = 1, ex = 1 ):
pm.deleteUI( 'ExportSets_Dock' )
floatingLayout = pm.paneLayout( configuration = 'single', w=300)
allowedAreas = ['right', 'left']
pm.dockControl('ExportSets_Dock', aa=allowedAreas, a='right', fl=False, con=floatingLayout, label='ExportSets', w=300)
pm.control('ExportSets_MainWindow', e=True, parent=floatingLayout)
pm.scriptJob(uid=['ExportSets_MainWindow', 'ExportsetsMain.OnClose()'], runOnce=True)
def closeEvent(self):
ExportsetsMain.OnClose()
-----the rest of the code follows after this
So, you can see that i have tried to set up 2 methods for a callback on close of my window. Before I made this thing dockable, overriding the closeEvent() actually worked. Ever since it became dockable, it stopped working, I presume because of parenting it to the pymel control.
However, the scriptjob doesn’t work properly either. It doesn’t fire on close, it fires on reopen! I assume this is because closing the dockable window doesn’t actually delete it? Or perhaps I’m attaching the scriptjob to the wrong UI? I’m kind of lost here; there is soooo little info on this stuff online, it’s crazy…