Reputation: 1
I would like to know how to change the text in a text field after creation via python for Maya? This sounds simple enough, but I cannot figure it out. I know how to change the text before creation. below is an example of how to change it before creation.
blendFilePathReadOnly = mc.textField(tx = "", ed = True)
Upvotes: 0
Views: 6601
Reputation: 5885
def changeTextFld(*args):
cmds.textField("nameOfTexFld", edit=True, tx="Foo Bar")
window = cmds.window()
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'right', 0), columnWidth=[(1, 100), (2, 250)] )
cmds.text( label='Name' )
name = cmds.textField("nameOfTexFld", tx="Test")
cmds.button( label='Button 1', command=changeTextFld )
cmds.showWindow( window )
You can always use edit command and if you are in same function then simply
name = cmds.textField(tx="Test")
...
cmds.textField(name, tx="Foo Bar")
Or if you using you can store in a class var something like this
self.name = cmds.textField(tx="Test")
...
def someFunc(self, *args):
cmds.textField(self.name, tx="Foo Bar")
Upvotes: 3