Maya的cmds.textField取值原来并不是返回值就是字符串,有点类似消息机制,代码:
import maya.cmds as cmds
def Foobar(arg):
print(arg)
def Main(*args):
if cmds.window("win", exists = True):
cmds.deleteUI("win")
win = cmds.window("win", w=280, h=75, t="Example")
cmds.columnLayout()
a = cmds.textField(tx='...')
cmds.button(label = 'Hello', command = lambda x:Foobar(cmds.textField(a, q=1, tx=1)))
cmds.separator(h=10)
cmds.window(win, e=True, w=280, h=75)
cmds.showWindow(win)
Main()
执行后: