Just a suggestion, but you may find it a lot easier to work with actual 
function objects, as opposed to passing a string for the callback, to be 
evaluated. When you pass a string it is not a closure and anything in there 
will get evaluated when it is executed. So you could change your callback to 
this (using one of my favorite python tools: functools.partial):

    from functools import partial
    callback = partial(AlphaValue, diffuseAmountSlider, "diffuseColorAmount")

the partial() function will take a function and its arguments and wrap them up 
into a single callable object, which you can then pass around. You could even 
pass more arguments to that new callable, which will be added onto the final 
call:

    def colors(required, optional1=None, optional2=None):
        print required, optional1, optional2

    colorFunc = partial(colors, optional2='red')
    colorFunc('green')
    # green None red



On May 26, 2013, at 12:12 AM, Daz wrote:

> Heya
> 
> I'm working on something similar but I get strange error. Could any have a 
> look at my piece of code too and let me know why I don't get call back of the 
> value I put in to my slider?
> 
> import maya.cmds as cmds
> 
> def AlphaValue(SliderName,AlphaName):
>       if cmds.ls(sl=1,mat=1):
>               sel=cmds.ls(sl=1,mat=1)
>               for alpha in sel:
>                       value=cmds.floatSliderGrp(SliderName,query= 
> True,field=True)
>                       print value
>                       cmds.setAttr('%s.%s'%(alpha,AlphaName),value[0])
> 
> windowZ=cmds.window(title="Slider Test",w=350,h=250)
> cmds.columnLayout(w=150,adj=True)
> diffuseAmountSlider=cmds.floatSliderGrp(label="Zoom", 
> field=True,dc='AlphaValue(diffuseAmountSlider,"diffuseColorAmount")',value=1,min=-0.001,max=1,pre=3)
> cmds.showWindow(windowZ)
> 
> I cant break it no matter what I try :( 
> 
> -- 
> 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 post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to