Hi guys, Say I have a small script that upon pressing a button, it lists all ncloth nodes in my scene and displays them as buttons somewhere on my UI, how can I do that upon pressing this new buttons, it runs a function that only affects the nCloth node represented by the pressed button?
So far I have something like this, but Iām missing the functionality to (at the moment) just print the name of the pressed button. Any help would be gladly appreciated 
import maya.cmds as cmds
def printButtonName (buttonName):
print ('You pressed button named: ' + buttonName)
def listClothObjs(*args):
theExistingButtons = cmds.scrollLayout ('nClothScrollList', query=True, childArray=True)
if theExistingButtons > 0:
for theButton in theExistingButtons:
cmds.deleteUI (theButton)
theNodes = cmds.ls (type='nCloth')
for node in theNodes:
cmds.setParent ('nClothScrollList')
cmds.button ((node + '_button'), backgroundColor=(.2,.2,.2),width=120, command= printButtonName)
if (cmds.window('theWin', exists=True)):
cmds.deleteUI('theWin')
cmds.window('theWin', title="The Window")
cmds.columnLayout()
cmds.button ('listnCloth', command= listClothObjs)
cmds.scrollLayout ('nClothScrollList', w=125 , h=150, backgroundColor=(0,0,0) )
cmds.setParent ('..')
cmds.showWindow ('theWin')