Is it possible to pass functions into Maya optionMenuGrp (combobox-alike)?
I have done up a simple UI where I have this combobox (maya cmds not PyQt) and there are 2 options in it.
I tried out using the following code but I was prompted with errors in the menuItem statements:
# Error: non-keyword arg after keyword arg
# File "<maya console>", line 9
# SyntaxError: non-keyword arg after keyword arg #
Then I tried playing around with the placement of test1_func() or test2_func, it print out the statement as the code is executed but not executing it anymore if I tried to select the second menu item…
My code:
import maya.cmds as cmds
cmds.window(w=150, h=100)
cmds.columnLayout(adjustableColumn=True)
form = cmds.formLayout(numberOfDivisions=100)
exportSelection = cmds.optionMenuGrp(label=' Selection Options ', columnWidth=(1, 90))
test1 = cmds.menuItem(label='Export using item selection range', c = test1_func())
test2 = cmds.menuItem(test2_func(), label='Export using time slide range', c = test2_func())
startLbl = cmds.text( label='Start' )
start = cmds.textField(startLbl, w = 100, h = 20)
endLbl = cmds.text( label='End' )
end = cmds.textField(endLbl, w = 100, h = 20)
cmds.formLayout(form, edit=True, attachForm=[\
(exportSelection, 'top', 5),\
(exportSelection, 'left', 5),\
(startLbl, 'top', 40),\
(startLbl, 'left', 7),
(start, 'top', 35),\
(start, 'left', 45),
(endLbl, 'top', 60),\
(endLbl, 'left', 7),
(end, 'top', 60),\
(end, 'left', 45)])
def test1_func(*args):
print "option 1 is selected"
def test2_func(*args):
print "option 2 is selected"
cmds.showWindow()