Lambdas are particularly confusing, too. Your original attempt
command=lambda *x: self.add_btn_callback("item_list")
doesn't actually call the function add_btn_callback, even though it looks 
like it does. It creates a new function that will call add_btn_callback 
later.

I prefer partial instead, because it seems clearer to me what is happening. 
partial is similar to lambda. It creates a new function that will call your 
function with given arguments:
from functools import partial
...
command=partial(add_btn_callback, "item_list")

And I should warn you: right now your argument is a constant string 
"item_list". Things get even weirder if you have arguments whose values 
might be different when the button is clicked than they are now.


On Wednesday, 15 March 2017 11:49:31 UTC+11, Justin Israel wrote:
>
>
>
> On Wed, Mar 15, 2017 at 1:40 PM likage <[email protected] <javascript:>> 
> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/1789febb-1aed-4918-b25d-141fd48b0656%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/1789febb-1aed-4918-b25d-141fd48b0656%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/81cdcc57-51c2-497b-a3fc-fd681b851024%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to