你試圖完成的是從按鈕上按文本字段查詢文本值。
例子,如何做到這一點:
import maya.cmds as cmds
def createWindow():
windowID = 'window'
if cmds.window(windowID, exists = True):
cmds.deleteUI('window')
window = cmds.window(windowID)
cmds.rowColumnLayout()
cmds.textFieldGrp('textField_A', label = 'Textfield A: ')
cmds.textFieldGrp('textField_B', label = 'Textfeild B: ')
cmds.button(label = 'pass textfield values', command = queryTextField)
cmds.showWindow(window)
def queryTextField(*args):
text_A = cmds.textFieldGrp('textField_A', query = True, text = True)
text_B = cmds.textFieldGrp('textField_B', query = True, text = True)
print text_A, text_B
createWindow()
您查詢文本字段的值,或與以下行textfieldGrp。
text_A = cmds.textFieldGrp('textField_A', query = True, text = True)