vendredi 8 juillet 2016

Printing the label of a button when clicked

So I'm trying to output the label of the button as it's pressed (Button label should replace the XXX in the print of the buttonNumber function). I do not know how to retrieve the label data from the button to output. Any thoughts? Thanks in advance

import maya.cmds as mc

def buttonNumber(*args):
    print 'Button XXX was pressed'

def openWindow():
    if mc.window('windowTest', ex=True):
        mc.deleteUI('windowTest', window=True)

    mc.window('windowTest', title='', s=True, resizeToFitChildren = True,)
    mc.rowColumnLayout(numberOfColumns = 3, columnWidth = [ (1, 150), (2, 150), (3, 150)])
    mc.button(label='1', command=buttonNumber)
    mc.button(label='2', command=buttonNumber)
    mc.button(label='3', command=buttonNumber)
    mc.button(label='4', command=buttonNumber)
    mc.button(label='5', command=buttonNumber)
    mc.button(label='6', command=buttonNumber)
    mc.button(label='7', command=buttonNumber)
    mc.button(label='8', command=buttonNumber)
    mc.button(label='9', command=buttonNumber)
    mc.showWindow('windowTest')

openWindow()

Aucun commentaire:

Enregistrer un commentaire