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.
However only then I realized that I am unable to 'call' out the function,
nor are there any similar flags to it in its documentation (maybe there is
but I do not know of it yet...)
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', test1_func
())
test2 = cmds.menuItem(test2_func(), label='Export using time slide range',
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()
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/64b66ab8-a585-4b25-8322-f62e431daced%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.