• Blog
  • Work
  • Resources
    • Rigs
  • Resume
  • Contact
I do technical things...

Python Api Close Window CallBack

12/1/2011

1 Comment

 
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.

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 )

apideleteuicallback.py
File Size: 1 kb
File Type: py
Download File

1 Comment
technical writing course in pune link
10/5/2012 05:37:31 pm

Its been wow reading your article. I would like to jump on this site again. This information is excellent, as share good stuff with good concept

Reply



Leave a Reply.

    Andy T.

    I do Tech things for Artist.

    Archives

    July 2014
    February 2014
    January 2014
    April 2013
    August 2012
    March 2012
    February 2012
    December 2011
    July 2010

    Categories

    All
    3ds Max C#
    3ds Max .net Api
    Animation
    Api
    Face Rig
    Maxscript
    Maya
    Mel
    Python
    Python Api
    Rigging
    Scripting
    Ui
    Work

    Links To Cool Folks

    Mic Marvin
    Alex Utting
    Rick Vicens
    Gary Talbot
    Richie Prado
    Felipe Nogueira

    RSS Feed