Due to certain constraints, I can't use a class for this, like I normally would.
I need to pass a function a variable, but the function is inside another function.
Here's the code I'm using, please be gentle, I'm not a python wizard and I'm self-taught. The problem I'm running into is nButtons is returning False in my function reColor.
import maya.cmds as cmds
nButtons = 4
def ColorMeButtonsUI(nButtons):
def reColor(nButtons):
for i in range(nButtons):
cmds.button(str(i), edit = True, bgc = (1,1,1))
if cmds.window('colorUI', exists= True):
cmds.deleteUI('colorUI')
if not nButtons:
nButtons = 3
if nButtons >= 2 and nButtons < 10:
colorUI = cmds.window('colorUI', title='Color me, Buttons', widthHeight=(200, 55), rtf = True )
cmds.columnLayout( adjustableColumn=True)
cmds.button('Color', label='Color', command = reColor)
for i in range(nButtons):
cmds.button(str(i), label = 'Color'+str(i+1))
cmds.setParent( '..' )
cmds.showWindow( colorUI )
else:
cmds.error ('Input is invalid. Please confirm input >1 and <10')
return nButtons
ColorMeButtonsUI(nButtons)
edit: the command is being run by a GUI button: cmds.button('Color', label='Color', command = reColor)