Post Post Edit! I found a much easier way to do this. :D
scriptJob -uiDeleted "uiName" "someFunction";
Ah well, I learned something anyway!
----------------------------------------------------------------------------------------------------------
Add a callback when a window is closed.
Can come in really handy when you have heavy ui usage and require post tool cleanup or whatever.
scriptJob -uiDeleted "uiName" "someFunction";
Ah well, I learned something anyway!
----------------------------------------------------------------------------------------------------------
Add a callback when a window is closed.
Can come in really handy when you have heavy ui usage and require post tool cleanup or whatever.
from maya import OpenMaya
from maya import OpenMayaUI
import maya.cmds as cmds
def makeTestWindow():
window = cmds.window( 'TEST_WIN', title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Do Nothing' )
cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.setParent( '..' )
cmds.showWindow( window )
return window
def uiDeleteCallback( *args ):
"""
This is the function that will be called whenever the ui, passed to the MUiMessage.addUiDeletedCallback( window, uiDeleteCallback )
is deleted
"""
cmds.confirmDialog(-message "The Window Was Closed!!!")
# make a test window
win = makeTestWindow()
# create the callback to run when the ui is deleted
uiCallBack = OpenMayaUI.MUiMessage.addUiDeletedCallback( win, uiDeleteCallback )
# removes the callback from memory
#OpenMaya.MMessage.removeCallback( uiCallBack )
from maya import OpenMayaUI
import maya.cmds as cmds
def makeTestWindow():
window = cmds.window( 'TEST_WIN', title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Do Nothing' )
cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.setParent( '..' )
cmds.showWindow( window )
return window
def uiDeleteCallback( *args ):
"""
This is the function that will be called whenever the ui, passed to the MUiMessage.addUiDeletedCallback( window, uiDeleteCallback )
is deleted
"""
cmds.confirmDialog(-message "The Window Was Closed!!!")
# make a test window
win = makeTestWindow()
# create the callback to run when the ui is deleted
uiCallBack = OpenMayaUI.MUiMessage.addUiDeletedCallback( win, uiDeleteCallback )
# removes the callback from memory
#OpenMaya.MMessage.removeCallback( uiCallBack )

apideleteuicallback.py |