Hi,
I’m trying to understand why I’m getting the response I’m getting :banghead:
For the tool I’m writing I am trying form layout. I have a temp buttons in just to get this figured out. I have three forms, Top, left side, right side. The right side is a columnLayout. All I’m trying to do is get new buttons to go into the right side column. Ultimately the user will have lots of things they can add and remove from the right side but I’m just starting out with a button to make it easy.
What I expect to happen is I run the script, it shows a window, I click the “Add A Button” button and it creates a new button. It’s supposed to parent the new button inside the “right side” column. The first button just goes to the upper left corner of the window. Subsequent buttons go into the column though.
This could even be the completely wrong way of having the user add options into a column.
Why doesn’t my first button parent inside the column but all subsequent buttons do?
import maya.cmds as cmds
def mkBtn(pargs):
temp = cmds.button(label = 'New Button')
cmds.setParent(rightSide)
window = cmds.window(w=200, h=200)
form = cmds.formLayout(numberOfDivisions=100)
topSide = cmds.button(label="Add A Button", command = partial(mkBtn))
leftSide = cmds.button(label = "REPLACE WITH OTHER STUFF", command = partial(mkBtn))
rightSide = cmds.columnLayout(w=100)
cmds.button()
cmds.setParent("..")
cmds.formLayout( form, edit=True, af=[(topSide, 'top', 5), (topSide, 'left', 5), (topSide, 'right', 5), (leftSide, 'bottom', 5),(leftSide, 'left', 5), (rightSide, 'right', 5), (rightSide, 'bottom', 5) ],
ac=[(leftSide,'top',5, topSide), (rightSide, 'top',5,topSide),(leftSide, 'right', 5, rightSide)])
cmds.showWindow( window )