【发布时间】:2021-02-07 09:53:07
【问题描述】:
以下代码取自此处的 Pymel 文档:https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/PyMel/generated/functions/pymel.core.windows/pymel.core.windows.layoutDialog.html
虽然该示例名为checkboxPrompt,但它并未显示如何检索复选框的状态。 pm.layoutDialog 函数仅返回用于关闭对话框的按钮选择。同一命令的 MEL 和 Maya.cmds 文档也没有对此进行解释。那么它是如何实现的呢?
import pymel.core as pm
def checkboxPrompt():
# Get the dialog's formLayout.
#
form = pm.setParent(q=True)
# layoutDialog's are not resizable, so hard code a size here,
# to make sure all UI elements are visible.
#
pm.formLayout(form, e=True, width=300)
t = pm.text(l='What do you want to do?')
b1 = pm.button(l='Abort', c='pm.layoutDialog( dismiss="Abort" )' )
b2 = pm.button(l='Skip', c='pm.layoutDialog( dismiss="Skip" )' )
b3 = pm.button(l='Continue', c='pm.layoutDialog( dismiss="Continue" )' )
cb1 = pm.checkBox(label='Remember my choice')
spacer = 5
top = 5
edge = 5
pm.formLayout(form, edit=True,
attachForm=[(t, 'top', top), (t, 'left', edge), (t, 'right', edge), (b1, 'left', edge), (b3, 'right', edge), (cb1, 'left', edge), (cb1, 'bottom', spacer)],
attachNone=[(t, 'bottom'), (b1, 'bottom'), (b2, 'bottom'), (b3, 'bottom'), (cb1, 'right')],
attachControl=[(b1, 'top', spacer, t), (b2, 'top', spacer, t), (b3, 'top', spacer, t), (cb1, 'top', spacer, b1)],
attachPosition=[(b1, 'right', spacer, 33), (b2, 'left', spacer, 33), (b2, 'right', spacer, 66), (b3, 'left', spacer, 66)])
print pm.layoutDialog(ui=checkboxPrompt)
【问题讨论】:
标签: user-interface maya pymel