self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add object(s)', image='add.xpm', command=lambda * args:self.btnCallback("add", "item_list") )def uiListCallback(self, *args):
mode = args[0]text_list = args[1]
if mode == "add":
# do this
elif mode == "remove"
# do that
def greet():
print 'hello'
def main():
cmds.window()
cmds.columnLayout()
cmds.symbolCheckBox(image='circle.png', changeCommand=greet())
cmds.showWindow()
main()def greet():
print 'hello'
def main():
cmds.window()
cmds.columnLayout()
# () was added into greet under the command flag
cmds.symbolCheckBox(image='circle.png', command=greet())
cmds.showWindow()
main()I will get `# Error: TypeError: file <maya console> line 9: Invalid arguments for flag 'changeCommand'. Expected string or function, got NoneType # `
import maya.cmds as cmds def greet(value): print 'greet was called with value: {0}'.format(value)
print 'hello'
def main():
cmds.window()
cmds.columnLayout()
# () was added into greet under the command flag
cmds.symbolCheckBox(image='circle.png', changeCommand=greet)
cmds.showWindow()
main()self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add object(s)', image='add.xpm', command=self.add_btn_callback("item_list") )
def add_btn_callback(self, "list"):
# Do the exec when add button is clickedTry wrapping it in a lambda?self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add object(s)', image='add.xpm', command=lambda *x: self.add_btn_callback("item_list") )
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4f0ec7aa-064a-415d-a295-0a1de7f6e430%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From the flags, though it mentions of `script` I had assumed that it will worked with a normal method too..
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1789febb-1aed-4918-b25d-141fd48b0656%40googlegroups.com.
command=lambda *x: self.add_btn_callback("item_list")
from functools import partial
...
command=partial(add_btn_callback, "item_list")On Wed, Mar 15, 2017 at 1:40 PM likage <dissid...@gmail.com> wrote:From the flags, though it mentions of `script` I had assumed that it will worked with a normal method too..This refers to the ability to pass script logic in string form. In MEL there are no first class functions so your only option is to pass a string with MEL script to run. In python you can either pass Python script to be evaluated, or a callable object.
--
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 python_inside_maya+unsub...@googlegroups.com.