Yep I'm cooking with oil now! :-D

Can't thank you guys enough for helping me with these first basic steps.

-Tim


On Wed, Apr 23, 2014 at 8:57 AM, Tony Barbieri <[email protected]> wrote:

> Nope, that should be fine!
>
> I only mentioned the lambda way of dealing with it if you didn't want your
> callable to accept *args and/or **kwargs.  I don't like to blanket add
> *args and **kwargs if it doesn't fit the design of my code.  In a lot of
> situations the code I'm writing is being used in multiple places, calling
> via a menu just being one of those, so I don't like the menu influencing
> how I have to write the code.
>
> In the above example you gave using a lambda it should have worked if you
> added parentheses after runThis:
>
> *cmds.menuItem(p=shotsMenu, l='Shot Setup', command=lambda *args,
> **kwargs: *runThis()*)*
>
>
> On Wed, Apr 23, 2014 at 9:36 AM, Tim Crowson <[email protected]> wrote:
>
>> Thanks guys! I would much rather use a simple function for the command
>> and not use the instance at all, but I wasn't able to get that to work
>> until I read the section linked above on "positional arguments". I've got
>> it working now and it's much more straightforward. The problem I was having
>> was that if I had a function in my menu plugin called something like this:
>>
>> *def runThis():*
>> *    print 'running'*
>>
>> I was trying to assign it to a command like this:
>> *cmds.menuItem(p=shotsMenu, l='Shot Setup', command=lambda *args,
>> **kwargs: *runThis*)*
>>
>> But in fact, all I needed to do was this:
>>
>> *def runThis(*args):*
>> *    print 'running'*
>> *...*
>>
>> *cmds.menuItem(p=shotsMenu, l='Shot Setup', command=runThis) *
>>
>>
>> And that seems to be working fine. So no more dangling instances.
>> Anything off about doing it this way?
>>
>>
>> -Tim
>>
>>
>>
>> On Wed, Apr 23, 2014 at 8:13 AM, finale.ad1492 
>> <[email protected]>wrote:
>>
>>> Hi, Tim,
>>>
>>> there are 2 links might let you understand more about how to add UI
>>> widget callbacks.
>>> I found them pretty useful when I started writing python script in maya.
>>>
>>> ther first is from maya document, please scroll down of the page to
>>> find "positional arguments" part.
>>>
>>> http://download.autodesk.com/global/docs/maya2014/en_us/files/Python_Using_Python.htm
>>>
>>> the second is from pymel document. some methods of adding callback
>>> functions have been listed,
>>> and detailed with pros and cons.  this one should be very helpful!
>>> http://download.autodesk.com/global/docs/maya2014/en_us/PyMel/ui.html
>>>
>>> and if you really want to use object as a callback function,
>>> you will probably have to implement __call__() method in you object.
>>> you can take a look of pymel Callback object for detail.
>>> but just like Marcus and Justin said, function is really capable of
>>> doing this, really!
>>>
>>> hope these 2 links help!
>>>
>>>
>>>>>>   --
>>> 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/980ec257-8e19-4ce9-90a3-aa308debf5ce%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/980ec257-8e19-4ce9-90a3-aa308debf5ce%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/CAPh%3D1bnaV85AgaaV3vfO%3DzQqjnbLXLu4NSzLAfDoFX9%3DR5V64Q%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAPh%3D1bnaV85AgaaV3vfO%3DzQqjnbLXLu4NSzLAfDoFX9%3DR5V64Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> -tony
>
> --
> 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/CAJhmvsQi8VkM_5grymJ8zymG_V%2B8M1sx64-o-GxTHWZu_sCYLw%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAJhmvsQi8VkM_5grymJ8zymG_V%2B8M1sx64-o-GxTHWZu_sCYLw%40mail.gmail.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/CAPh%3D1bmAHUvZ4xVfs-B%2Bx71keO-qVWruf6d14sp958iGegz_Yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to