[Maya][Python] Can I trigger UI changeCommands programmatically?

Is there a way to toggle the state/value of a checkbox and have the changeCommand be triggered?

you can query the -cc flag and execute the result if it’s Python, since you already know the control if you’re setting the value.

-cc isn’t a query-able flag according to the docs, and returns None in my tests

:confused:

It returns the proc name for mel, but ‘’ for Python for me (2015). I may be confusing default cmds with mGui here…

this works, but its unsustainable bullshit:


def test(*args):
    print "XXX"
    print args, "!!!"

globals()['test'] = test

w = cmds.window()
c = cmds.columnLayout()
e = cmds.checkBox(cc = 'test')

cmds.showWindow(w)
eval (cmds.checkBox(e, q=True, cc=True) + "()")

Don’t do it this way, it’s evil. Is the gui you need to control your own, or somebody else’s?

Its its your GUI you could wrap its constructor in your own class, and have it keep track of the change command call back as its own attribute.

Actually rather easy to wrap things since python has *args and *kwargs

It’s my own. My next step was to wrap the checkBox command but figured I’d see if there was a way to get it otherwise. Thanks