Python 带有选项按钮的双重回调
当我在两个选项之间切换时,它总是返回双结果tex,tex/sculpt,sculpt。它也发生在我过去的项目中,但我从未解决过。重新启动maya不起作用,即使使用重写的代码,它也会不断发生。有什么建议吗Python 带有选项按钮的双重回调,python,button,maya,Python,Button,Maya,当我在两个选项之间切换时,它总是返回双结果tex,tex/sculpt,sculpt。它也发生在我过去的项目中,但我从未解决过。重新启动maya不起作用,即使使用重写的代码,它也会不断发生。有什么建议吗 import maya.cmds as cmds class UI(object): def __init__(self): a=cmds.window() cmds.showWindow(a) cmds.columnLayout()
import maya.cmds as cmds
class UI(object):
def __init__(self):
a=cmds.window()
cmds.showWindow(a)
cmds.columnLayout()
self.displaceOptions = cmds.radioButtonGrp(la2=['Texture', 'Sculpting'], nrb=2, en=True, cc=self.check)
def check(self, *args):
option = cmds.radioButtonGrp(self.displaceOptions, q=True, sl=True)
if option == 1:
self.dispTexture()
elif option == 2:
self.dispSculpt()
def dispTexture(*args):
print('tex')
def dispSculpt(*args):
print('sculpt')
UI()
原因是changeCommand对两次更改的状态更改作出反应,首先禁用一个单选按钮,然后激活另一个单选按钮。UI的第一次调用没有选择单选按钮,如果选择单选按钮,则只调用一次回调,因为状态只更改一次。 您可以使用onCommand或offCommand,它们的行为应该更符合您的预期