Maya Pymel:将 fileDialog2 的 return 传递给 UI 文本字段
Maya Pymel: pass fileDialog2's return to a UI textfield
我无法理解如何使用 fileDialog2 的 "optionsUICommit" 标志。当用户在文件对话框中点击"save"时,我想运行命令on_save_dialog_file
。但是从帮助文件来看,似乎要我使用MEL命令。
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/index.html
MEL only. The string is interpreted as a MEL callback, to be called
when the dialog is successfully dismissed. It will not be called if
the user cancels the dialog, or closes the window using window title
bar controls or other window system means. The callback is of the
form: global proc MyCustomOptionsUICommit(string $parent)
The parent argument is the parent layout into which controls have been
added using the optionsUICreate flag
这似乎...复杂。
这是我的代码。
import pymel.core as pm
def on_save_dialog_file(myDialog):
print "Hello from file_dialog_save_file()!"
def file_dialog_save_file():
myDialog = pm.fileDialog2(ocm="on_save_dialog_file", fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2)
print myDialog
file_dialog_save_file()
即使尝试使用奇怪的 Mel->Python 命令也没有用。 ocm="python \"on_save_dialog_file()\";"
在对话框中设置保存文件后,是否有easier/more直接运行命令的方法?
你可以这样做,没有回调。除了用户选择之外的任何内容都将 return None
c = cmds.fileDialog2(fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2)
if c:
print c
else:
print "user cancelled"
我在处理 FileDialog2 时想到的一点是,它 returns 数组中所选 file/directory 的路径。如果要使用返回信息的字符串值,则必须先指定数组的一部分。
c = mc.fileDialog2(fm=3, dialogStyle=2)
k = c[0]
print(str(k))
我无法理解如何使用 fileDialog2 的 "optionsUICommit" 标志。当用户在文件对话框中点击"save"时,我想运行命令on_save_dialog_file
。但是从帮助文件来看,似乎要我使用MEL命令。
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/index.html
MEL only. The string is interpreted as a MEL callback, to be called when the dialog is successfully dismissed. It will not be called if the user cancels the dialog, or closes the window using window title bar controls or other window system means. The callback is of the form: global proc MyCustomOptionsUICommit(string $parent)
The parent argument is the parent layout into which controls have been added using the optionsUICreate flag
这似乎...复杂。
这是我的代码。
import pymel.core as pm
def on_save_dialog_file(myDialog):
print "Hello from file_dialog_save_file()!"
def file_dialog_save_file():
myDialog = pm.fileDialog2(ocm="on_save_dialog_file", fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2)
print myDialog
file_dialog_save_file()
即使尝试使用奇怪的 Mel->Python 命令也没有用。 ocm="python \"on_save_dialog_file()\";"
在对话框中设置保存文件后,是否有easier/more直接运行命令的方法?
你可以这样做,没有回调。除了用户选择之外的任何内容都将 return None
c = cmds.fileDialog2(fm=0, ff="Maya Files (*.ma *.mb);;Maya ASCII (*.ma);;Maya Binary (*.mb);;All Files (*.*)", dialogStyle=2)
if c:
print c
else:
print "user cancelled"
我在处理 FileDialog2 时想到的一点是,它 returns 数组中所选 file/directory 的路径。如果要使用返回信息的字符串值,则必须先指定数组的一部分。
c = mc.fileDialog2(fm=3, dialogStyle=2)
k = c[0]
print(str(k))