Hey guys! I am messing around with something I was hoping someone could help shed some light on…
I’m trying to figure out how one alters the changeCommand of a textField (in pymel) after the UI has been established. Take the following code sample:
import pymel.core as pm
win = pm.window()
cl = pm.columnLayout( p=win )
rcl = pm.rowColumnLayout( nc=1, cw=[1,250], p=cl )
tf1 = pm.textField( p=rcl )
tf2 = pm.textField( cc= lambda *args: printStuff('whatever'), p=rcl )
pm.showWindow(win)
def printStuff( theStuff, *args ):
print "%s" % theStuff
The top textField is not hooked up, but the bottom one is. Typing anything in the bottom field will print “whatever”. Now that the window is established, I want to alter the changeCommand of the top (tf1) textField.
Below are my failed attempts:
# Both these attempts end up pointing the changeCommand to a function
# instead of the expected bound method TextField.changeCommand
# so this is clearly the wrong way
tf1.changeCommand = pm.windows.Callback( printStuff, 'hello' )
tf1.changeCommand = lambda *args: printStuff('hello')
The docs say:
changeCommand(val=True, **kwargs)¶
Command executed when the text changes. This command is not invoked when the value changes via the -tx/text flag. Derived from mel command maya.cmds.textField
Any help on this would be appreciated!
-csa