【发布时间】:2021-07-20 10:17:26
【问题描述】:
在一个表单中嵌入多个 PyMEL 布局的最佳方式是什么?
例如,对于表单的每一行,我想指定:
- 第一行对 label+textField 对使用 2 列布局
- 第二行对具有自己注释标签的菜单项使用 1 列布局
- 第三行在 1 列布局中添加了一个全角执行按钮
- 如果用户调整窗口大小,所有控件都会适当缩放
TIA!
import pymel.core as pm
def test(*args):
print('model name: {}'.format(modelTField.getText()))
print('model geom: {}'.format(modelMenu.getValue()))
if pm.window("testUI", ex=1): pm.deleteUI("testUI")
window = pm.window("testUI", t="Test v0.1", w=500, h=200)
mainLayout = pm.verticalLayout()
# two column layout
col2Layout = pm.horizontalLayout(ratios=[1, 2], spacing=10)
pm.text(label='Model name')
global modelTField
modelTField = pm.textField()
col2Layout.redistribute()
# single column layout
col1Layout = pm.horizontalLayout()
global modelMenu
modelMenuName = "modelMenu"
modelMenuLabel = "Model mesh"
modelMenuAnnotation = "Select which geo corresponds to the model shape"
modelMenu = pm.optionMenu(modelMenuName, l=modelMenuLabel, h=20, ann=modelMenuAnnotation)
pm.menuItem(l="FooShape")
pm.menuItem(l="BarShape")
# execute
buttonLabel = "[DOIT]"
button = pm.button(l=buttonLabel, c=test)
col2Layout.redistribute()
# display window
pm.showWindow(window)
【问题讨论】: