Reputation: 61
Want to setup a radio button when button state change to update text label. Here the code bolow. Thanks a lot.
import maya.cmds as cmds
import pymel.core as pm
class Ui():
def __init__(self):
windowID = 'testWin'
uiName = "Test Win"
if pm.window(windowID, exists=1):
pm.deleteUI(windowID)
tmpl = pm.uiTemplate(windowID+'_uiTmpl', force=1)
wnd = pm.window(windowID, t=uiName, s=1, rtf=1, toolbox=1)
with tmpl:
with pm.horizontalLayout() as skinLayout1:
pm.radioCollection("tmp")
pm.radioButton("tmpX", l="X", da=0, onc=self.switchCmd())
pm.radioButton("tmpY", l="Y", da=1, onc=self.switchCmd(), sl=1)
pm.radioButton("tmpZ", l="Z", da=2, onc=self.switchCmd())
pm.checkBox("checkBox", l="X", v=1)
wnd.show()
def switchCmd(self, *arg):
if pm.radioButton("tmpX", q=1, sl=1) == 1:
dir = "Z"
elif pm.radioButton("tmpY", q=1, sl=1)== 1:
dir = "X"
elif pm.radioButton("tmpZ", q=1, sl=1) == 1:
dir = "Y"
pm.checkBox("checkBox", e=1, l=dir)
return
Ui()
Now I tried to code and got errors. "RuntimeError: Object 'tmpX' not found."
Upvotes: 0
Views: 73
Reputation: 1978
Your on command is not defined correctly, if you use self.switchCmd() the method will be executed directly, you will have to use onc=self.switchCmd without parentheses.
Upvotes: 2