将布局定位到主布局的底部 python Autodesk Maya

Position a layout to the bottom of main layout python Autodesk Maya

我正在创建一个用户界面,允许用户每次点击“+”按钮时添加一个带有文本字段的新布局,因为我知道我必须将该应用按钮放在我的底部主要布局,但我遇到的问题是添加的布局隐藏了我的应用按钮

这是我的代码:

import maya.cmds as cmds
from functools import partial
import pymel.core as pm

selectedEmotion = ""
def createUI(*args):
    windowID = 'myWindowID'
    if cmds.window(windowID, exists=True):
        cmds.deleteUI(windowID)
    cmds.window(windowID, title="User Interface", sizeable=True)
    cmds.scrollLayout(horizontalScrollBarThickness=10,verticalScrollBarThickness=10, parent=windowID)
    myLayout=cmds.rowColumnLayout(width=600, nr=3)
    layout1=cmds.rowColumnLayout(width=600, height=40, cs=[(1,5),(2,5),(3,5)],
    rowSpacing=[(1,30), (2,30), (3,30)], nc=3, cal=[(1, "center"),(2, "center"), (3,"center")], cw=[(1,60),(2,280),(3,50)], parent=myLayout)
    cmds.text(label="Browse: ", p=layout1)
    filenameField=cmds.textField(p=layout1, width=200)
    cmds.iconTextButton(style='iconOnly',align='center',command=partial(browseFile, filenameField), image1='fileOpen.xpm', height=30)
    layout2=cmds.rowColumnLayout(width=600, nc=2, cw=[(1,100),(2,100)], height=40, cs=[(1,40),(2,60)], parent=myLayout)
    layoutF=cmds.rowColumnLayout(width=600, nc=1, parent=myLayout)
    cmds.button(label="+", width=100, parent=layout2, command=partial(addRow,layoutF))
    cmds.button(label="-", width=100, parent=layout2, command=partial(addRow,layoutF))
    layout3=cmds.rowLayout(width=400,height=30, parent=myLayout)
    global globalFile
    cmds.button(label="Apply", width=130, parent=layout3, align='right')
    cmds.setParent('..')
    cmds.showWindow()
def addRow(pLayout, *args):
    layout2=cmds.rowLayout(parent=pLayout, width=390, nc=9, 
        cal=[(1, "center"),(2, "center"), (3,"center"), (4, "center"), (5,"center"),(6, "center"), (7,"center"), (8, "center")], 
        cw=[(1,25),(2,50),(3,25), (4,50), (5,50),(6,70),(7,50),(8,50)])
    cmds.text(label="From : ", p=layout2)
    fromField = cmds.textField(width=50)
    cmds.textField(fromField, edit=True, parent=layout2)
    cmds.text(label="To : ", p=layout2)
    toField = cmds.textField(width=50)
    cmds.textField(toField, edit=True, parent=layout2)
    cmds.text(label="Emotion : ", p=layout2)
    emotionList = cmds.optionMenu("objects", parent=layout2 )
    cmds.menuItem( label='Neutre', parent = "objects" )
    cmds.menuItem( label='Happy', parent = "objects" )
    cmds.menuItem( label='Sad', parent = "objects" )
    cmds.text(label="Position : ", p=layout2)
    positionField = cmds.textField(width=50)

createUI()  

我想通了。

这是我的代码,供任何需要帮助的人使用:

import maya.cmds as cmds
from functools import partial
import pymel.core as pm

selectedEmotion = ""
def createUI(*args):
    windowID = 'myWindowID'
    if cmds.window(windowID, exists=True):
        cmds.deleteUI(windowID)
    cmds.window(windowID, title="User Interface", sizeable=True)
    cmds.scrollLayout(horizontalScrollBarThickness=10,verticalScrollBarThickness=10, parent=windowID)
    myLayout=cmds.rowColumnLayout(width=600,ral=(4,"right"),columnAttach=(1,"both",0), nr=4,adj=True, rowAttach=(4, "bottom", 0))
    layout1=cmds.rowColumnLayout(width=600, height=40, cs=[(1,5),(2,5),(3,5)],
    rowSpacing=[(1,30), (2,30), (3,30)], nc=3, cal=[(1, "center"),(2, "center"), (3,"center")], cw=[(1,60),(2,280),(3,50)], parent=myLayout)
    cmds.text(label="Browse : ", p=layout1)
    filenameField=cmds.textField(p=layout1, width=200)
    cmds.iconTextButton(style='iconOnly',align='center',command=partial(browseFile, filenameField), image1='fileOpen.xpm', height=30)
    layout2=cmds.rowColumnLayout(width=600, nc=2, cw=[(1,100),(2,100)], height=40, cs=[(1,40),(2,60)], parent=myLayout)
    layoutF=cmds.rowColumnLayout(width=600, nc=1, parent=myLayout)
    global countClick
    countClick =0
    cmds.button(label="+", width=100, parent=layout2, command=partial(addRow,layoutF))
    cmds.button(label="-", width=100, parent=layout2, command=printCount)
    layout3=cmds.rowLayout(width=400,height=30, rowAttach=(1, "bottom", 0), parent=myLayout)
    cmds.button(label="Apply", width=130, parent=layout3, align='right')
    cmds.setParent('..')
    cmds.showWindow()
def addRow(pLayout, *args):
    global countClick
    countClick=countClick+1
    layout2=cmds.rowLayout(parent=pLayout, width=390, nc=9, 
        cal=[(1, "center"),(2, "center"), (3,"center"), (4, "center"), (5,"center"),(6, "center"), (7,"center"), (8, "center")], 
        cw=[(1,25),(2,50),(3,25), (4,50), (5,50),(6,70),(7,50),(8,50)])
    cmds.text(label="From : ", p=layout2)
    fromField = cmds.textField(width=50)
    cmds.textField(fromField, edit=True, parent=layout2)
    cmds.text(label="To : ", p=layout2)
    toField = cmds.textField(width=50)
    cmds.textField(toField, edit=True, parent=layout2)
    cmds.text(label="Emotion : ", p=layout2)
    emotionList = cmds.optionMenu("objects", parent=layout2 )
    cmds.menuItem( label='Neutre', parent = "objects" )
    cmds.menuItem( label='Happy', parent = "objects" )
    cmds.menuItem( label='Sad', parent = "objects" )
    cmds.text(label="Position : ", p=layout2)
    positionField = cmds.textField(width=50)