import maya.cmds as cmds
from functools import partial
def myFunc(set,*args):
print 'you chose ', set
occSets = ['A','B','C','D']
for i in occSets():
cmds.menuItem(l=i, c=partial(myFunc,i))
On Wed, Jan 12, 2011 at 6:08 AM, PixelMuncher <pixel...@gmail.com> wrote:
> Thanks Oren:
> I'm not familiar w/using classes, but I did try your suggestion.
> Assuming that I unwrapped your Class correctly:
> class Callback(object):
> def __init__(self, func, *args, **kwargs):
> self.func= func
> self.args = args
> self.kwargs = kwargs
> def __call__(self):
> return self.func( *self.args, **self.kwargs )
>
> When run the script, I get this error:
> # File "C:\Documents and Settings\Administrator\My Documents\maya
> \myScripts\panelContentChange.py", line 125
> # cmds.button(l='Sel',w=20, command =
> *Callback(selectMe,fullName)* )
> # ^
> # SyntaxError: invalid syntax #
>
> On Jan 11, 12:29 pm, Ofer Koren <kor...@gmail.com> wrote:
>> cmds.button(l='Sel',w=20, command = *Callback(selectMe,
>> fullName)* )
>>
>> - Oferwww.mrbroken.com
>>
>> On Tue, Jan 11, 2011 at 7:55 PM, PixelMuncher <pixeldr...@gmail.com> wrote:
>> > and this is the command I'm trying to assign to the buttons:
>> > def selectMe(who):
>> > print 'selectMe:',who
>> > cmds.select (who)
>>
>> > --
>> >http://groups.google.com/group/python_inside_maya
>>
>>
>
...
cmds.button(l='Sel',w=20, command = Callback(selectMe, fullName) )
- Ofer
www.mrbroken.com
On Tue, Jan 11, 2011 at 9:08 PM, PixelMuncher <pixel...@gmail.com> wrote:
>
> Thanks Oren:
> I'm not familiar w/using classes, but I did try your suggestion.
> Assuming that I unwrapped your Class correctly:
> class Callback(object):
> def __init__(self, func, *args, **kwargs):
> self.func= func
> self.args = args
> self.kwargs = kwargs
> def __call__(self):
> return self.func( *self.args, **self.kwargs )
>
> When run the script, I get this error:
> # File "C:\Documents and Settings\Administrator\My Documents\maya
> \myScripts\panelContentChange.py", line 125
> # cmds.button(l='Sel',w=20, command =
> *Callback(selectMe,fullName)* )
> # ^
> # SyntaxError: invalid syntax #
>
> On Jan 11, 12:29 pm, Ofer Koren <kor...@gmail.com> wrote:
> > cmds.button(l='Sel',w=20, command = *Callback(selectMe,
> > fullName)* )
> >
> > - Oferwww.mrbroken.com
> >
> > On Tue, Jan 11, 2011 at 7:55 PM, PixelMuncher <pixeldr...@gmail.com> wrote:
> > > and this is the command I'm trying to assign to the buttons:
> > > def selectMe(who):
> > > print 'selectMe:',who
> > > cmds.select (who)
> >
> > > --
> > >http://groups.google.com/group/python_inside_maya
> >
> >
>