我在 Maya 中的 GUI Exporter 遇到了最烦人的问题。我已经使 textField 等工作,但是在创建 textField 后我无法更改它的值,这是我需要做的。
例如,我想做的是,假设文件路径从一开始就没有。textField 现在已打印出:“None”,但在您按下浏览并选择一个目录后,我希望它将 None 更改为目录路径等。
这是我目前唯一遇到的问题,收到的错误代码是这样的:
错误:RuntimeError:文件 C:\Program Files\Autodesk\Maya2015\Python\lib\site-packages\pymel\internal\pmcmds.py 第 134 行:布局中的子级太多:rowLayout3 #
代码:
#Setup the window using the returned window
def setupWindow(self, new_window):
try:
frame_layout = pm.frameLayout(labelVisible = False, marginWidth = 5, marginHeight = 5)
pm.columnLayout(w = 350, h = 300)
pm.text(label = "Filepath: ")
self.textField = pm.textField("FieldNorm", text = "%s" % self.filePath, editable = False, w = 350, h = 20)
pm.button(label = "Browse", w = 100, h = 20, command = self.browse)
pm.rowLayout(numberOfColumns = 2, adjustableColumn = 1, w = 350, h = 25)
pm.button(label = "Export", w = 200, h = 25, command = self.export)
pm.button(label = "Close", w = 100, h = 25, command = pm.Callback(self.closeButton, new_window))
except:
print "<Setting up window failed>"
#Show the returned window
def showWindow(self, new_window):
if new_window is not None:
pm.showWindow(new_window)
else:
print "<Window does not exist!>"
#Browse Directory and Paste into textField
def browse(self, filePath):
self.filePath = pm.fileDialog2(dialogStyle = 2, returnFilter = 1, fileFilter = "*.obj")
if self.filePath is not None:
self.textField = pm.textField("FieldNorm", text = "%s" % self.filePath, editable = False, w = 350, h = 20)
else:
print "<No changes has been made!>"