創建於瑪雅UI我使用python創建在Maya中自定義UI和我卡在這個錯誤是在這條線出現:使用Python腳本
parts = button2.split(",") # NameError: global name 'button2' is not defined
這裏是我的腳本:
import maya.cmds as cmds
def createMyLayout():
window = cmds.window(widthHeight=(1000, 600), title="lalala", resizeToFitChildren=1)
cmds.rowLayout("button1, button2, button3", numberOfColumns=5)
cmds.columnLayout(adjustableColumn=True, columnAlign="center", rowSpacing=10)
button2 = cmds.textFieldButtonGrp(label="LocatorCurve",
text="Please key in your coordinates",
changeCommand=edit_curve,
buttonLabel="Execute",
buttonCommand=locator_curve)
cmds.setParent(menu=True)
cmds.showWindow(window)
def locator_curve(*args):
# Coordinates of the locator-shaped curve.
crv = cmds.curve(degree=1,
point=[(1, 0, 0),
(-1, 0, 0),
(0, 0, 0),
(0, 1, 0),
(0, -1, 0),
(0, 0, 0),
(0, 0, 1),
(0, 0, -1),
(0, 0, 0)])
return crv
def edit_curve(*args):
parts = button2.split(",")
print parts
createMyLayout()
基本上我的腳本是試圖創建一個用戶界面內的按鈕做東西。在這種情況下,我試圖創建一個用戶在一組座標中鍵入的文本字段按鈕,並根據給定的座標集創建基於定位器的曲線。但是,我只能設法創建一個創建默認曲線的按鈕。有人可以告訴我如何創建一個按鈕,考慮到一個人給出的座標並輸出特定的曲線?
你要必須向我們展示錯誤,或者我們無法弄清楚出了什麼問題...... – 2010-08-08 16:45:04
這是我得到的錯誤,parts = button2.split(「,」) #NameError:全球名稱'button2'沒有定義# 我想通過文本字段空間內的任何用戶密鑰,並打破它們並存儲em作爲創建曲線函數的變量。 但是,我不知道如何去做,所以我一直在隨機嘗試。我希望你們能給我一些關於如何去做的建議?謝謝! – Tom 2010-08-08 17:11:25