带选项按钮的双回调

问题描述 投票:0回答:1

当我在两个选项之间改变时,它总是返回双重结果(tex,texsculpt,sculpt)。我过去的项目也发生过这种情况,但我一直没有解决。重启Maya也没用,即使重写了代码也一直发生。有什么建议吗?

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()
python button maya
1个回答
1
投票

原因是changeCommand对状态变化的反应是两次,首先一个radiobutton被停用,然后另一个被激活。UI()的第一次调用没有选择单选按钮,如果你选择了一个,回调只被调用一次,因为状态只改变了一次.你可以使用onCommand,或者offCommand,这应该是你期望的行为。

© www.soinside.com 2019 - 2024. All rights reserved.