Разместите макет внизу основного макета Python Autodesk Maya - PullRequest
0 голосов
/ 24 июня 2019

Я создаю пользовательский интерфейс, который позволяет пользователю каждый раз, когда он нажимает кнопку «+», добавлять новый макет с текстовыми полями в нем, зная, что я должен поместить эту кнопку применения в нижней части основного макета., но проблема в том, что в добавленном макете скрыта кнопка «Применить»

, это мой код:

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()  

enter image description here

1 Ответ

0 голосов
/ 24 июня 2019

Я понял.

Это мой код для тех, кто нуждается в помощи:

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)
...