Hi, been giving Jeremy Ernst's UI tutorials a try and keep running up against 
this 'dict' object is not callable error when i attempt to create a scriptjob 
to change the button color back to its original after deselecting. 

The command itself is at line 67 and the input code is at line 26.I have not 
been using a dictionary at all in the process so I haven't been able to find 
the problem. Would appreciate if anyone with sharper eyes could spot where I've 
done wrong. 

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].


import maya.cmds as cmds
from functools import partial

class CharacterPicker():

    def __init__(self):

        self.widgets={}

        self.buildUI()


    def buildUI(self):

        if cmds.window("CharacterPicker_UI", exists=True):
            cmds.deleteUI("CharacterPicker_UI")

        self.widgets["window"]=cmds.window("CharacterPicker_UI", title="Character_Picker", w=400, h=500, mnb=False, mxb=False)

        self.widgets["mainLayout"] = cmds.columnLayout(w=400, h=400)
        self.widgets["formLayout"] = cmds.formLayout(w=400, h=400)

        self.widgets['headButton'] = cmds.button(label = "", w=40, h=40, bgc = [0,0.593,1])

        #buttonInfo =[(), ()]
        cmds.button(self.widgets['headButton'], edit=True, c=partial(self.selectControls, ['head'],[(self.widgets['headButton'],[0,0.593,1]) ] ))

        self.widgets['Spine03Button'] = cmds.button(label = "", w=100, h=40, bgc = [0.24,0.522,0.275],c=partial(self.selectControls,['spine_03']))
        self.widgets['Spine02Button'] = cmds.button(label = "", w=100, h=40, bgc =  [0.24,0.522,0.275],c=partial(self.selectControls,['spine_02']))
        self.widgets['Spine01Button'] = cmds.button(label = "", w=100, h=40, bgc =  [0.24,0.522,0.275],c=partial(self.selectControls,['spine_01']))

        cmds.formLayout(self.widgets['formLayout'], edit=True, af=[(self.widgets["headButton"],'left',220),(self.widgets["headButton"],'top', 100)])
        cmds.formLayout(self.widgets['formLayout'], edit=True, af=[(self.widgets["Spine03Button"],'left',190),(self.widgets["Spine03Button"],'top', 150)])
        cmds.formLayout(self.widgets['formLayout'], edit=True, af=[(self.widgets["Spine02Button"],'left',190),(self.widgets["Spine02Button"],'top', 200)])
        cmds.formLayout(self.widgets['formLayout'], edit=True, af=[(self.widgets["Spine01Button"],'left',190),(self.widgets["Spine01Button"],'top', 250)])

        cmds.showWindow(self.widgets["window"])

    def selectControls(self, controls, buttonInfo, *args):
        #buttonInfo=[[buttonName, buttonBGC]]

        #if shift held down
        mods = cmds.getModifiers()
        if(mods & 1) > 0:

            for control in controls:
                cmds.select(control, tgl=True )

        #if no modifiers
        else:
            cmds.select(clear=True)

            for i in range(len(controls)):

                cmds.select(controls[i], add=True)

                buttonName= buttonInfo[i][0]
                buttonBGC = buttonInfo[i][1]

                cmds.button(buttonName, edit=True, bgc=(1.0, 1.0, 1.0))
                ++i

                self.createSelectionScriptJob(controls[i], buttonName, buttonBGC)

    def createSelectionScriptJob(self, control, buttonName, buttonBGC):

        scriptJobNum = cmds.scriptJob(event = ["SelectionChanged", partial(self.deselectButton, control, buttonName, buttonBGC )], runOnce=True, parent= self.widgets("window"))


    def deselectButton(self, control, buttonName, buttonBGC):
        selection= cmds.ls(sl=True)

        if control not in selection:
            cmds.button(buttonName, edit=True, bgc=buttonBGC)

        else:
            self.createSelectionScriptJob(control, buttonName, buttonBGC)

CharacterPicker()

Reply via email to