RadioButton 开关更新复选框标签
RadioButton switch to update check box label
想要在按钮状态更改时设置单选按钮以更新文本标签。
下面是代码。非常感谢。
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()
现在我尝试编码并遇到错误。
“运行时错误:找不到对象 'tmpX'。”
你的on命令定义不正确,如果你使用self.switchCmd()方法将直接执行,你将不得不使用不带括号的onc=self.switchCmd。
想要在按钮状态更改时设置单选按钮以更新文本标签。 下面是代码。非常感谢。
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()
现在我尝试编码并遇到错误。 “运行时错误:找不到对象 'tmpX'。”
你的on命令定义不正确,如果你使用self.switchCmd()方法将直接执行,你将不得不使用不带括号的onc=self.switchCmd。