I did a little script with MEL and as an exercise I decided to translate it to Python. I have some interface controls defined within a def and some other commands querying those object's values within another def. When I try to query this way in Python it gives me an Error telling the object doesn't exist (because it is in the namespace of another def). An example:
import maya.cmds as cmds def changedValue () : if cmds.checkBox("myCHKBOX" , q = True, enable = True) != True : cmds.checkBox("myOtherCHKBOX" , e = True , enable = False) else : cmds.checkBox("myOtherCHKBOX" , e = True , enable = True) def createWindow (): cmds.window("myWindowUI" , title = "myWindowUI" , wh = (282,200) ) cmds.columnLayout("mainCol" , adj = True) cmds.checkBox("myCHKBOX" , label = "myCHKBOX" , v = False , changeCommand = changedValue()) cmds.checkBox("myOtherCHKBOX" , label = "myOtherCHKBOX" , v = True , enable = False) cmds.showWindow("myWindowUI")
This is the Error message: # Error: RuntimeError: file <maya console> line 5: Object 'myCHKBOX' not found. To solve this with MEL I define the proc as a "global proc" but I'm not sure if you can do this with Python. Thanks!!