Detecting Close Scene or Change Scene
Question: HI I'm working with `Pyqt4` to make a UI in `Maya`, but I want that the UI
close or refresh when the user open or change Scene.

Is there a way in python to detect this change?


Answer: [`scriptJob`](http://download.autodesk.com/us/maya/2010help/CommandsPython/scriptJob.html)
is what you need.

The following might with some customization might be helpful.

    
    
    import maya.cmds as cmds
    
    def refresher():
        # the function which does the closing/refreshing
        pass
    
    cmds.scriptJob(e=["NewSceneOpened", refresher])
    cmds.scriptJob(e=["SceneOpened", refresher])
    cmds.scriptJob(e=["flushingScene", refresher])
    

