mardi 10 mai 2016

Switchable Radio Buttons (editing a command)

I'm a bit stuck on how to write the correct syntax for editing a command.

way down in my radioOn and radioOff commands, I would like the enable / disable checkbox to enable or disable the radio buttons.

from functools import partial
import maya.cmds as cmds

def one ():
    print '1'

def two ():
    print '2'



winID = 'xx'
if cmds.window(winID, exists=True):
    cmds.deleteUI(winID)


window = cmds.window(winID, sizeable = False, title="Resolution Switcher", widthHeight=(300, 100) )

cmds.columnLayout( )
cmds.text (label = '')
cmds.text (label = '')
cmds.checkBoxGrp( cat = (1,'left', 20), ncb = 1, l1='  DISABLE', offCommand = partial(radioOn, a), onCommand = partial(radioOff, a) )
a = cmds.radioButtonGrp( cat = [(1,'left', 90),(2, 'left', 100)], numberOfRadioButtons=2,   on1 = 'one ()' , on2 = 'two ()' )
cmds.text (label = '')

def radioOff (a, *args):
    print 'radios off'
    a(ed=True, enable=False)

def radioOn (a, *args):
    print 'radios on'
    a(ed=True, enable=False)


cmds.showWindow( window )

I've tried to get an idea from examples such as the one shown here, but but when I put down cmds.radioButtonGrp(a, ed=True, enable=False) it just keeps creating new radio buttons, not unlike what was shown in the example with float fields.

bottom line is - I just want the radio buttons to be greyed out and disabled whenever I hit the checkbox. Speaking of which - Is it possible to grey out the radio buttons the same way float fields can? I noticed that disabling them only makes them unclickable - but not greyed out.

Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire