Search code examples
pythoncocoabindingpyobjc

How to bind a TextField to an IBOutlet()?


I'm trying to figure out how to update an NSTextField programatically.

I've figured out how to get the current value of the Text Field from Python:

myVar = objc.IBOutlet()
....
self.myVar.stringValue()

How do I set the value of myVar from the Python side and have the GUI update? I'd like some sort of two way binding (like {myVAR} in Flex).

Thanks!


Solution

  • How do I set the value of myVar from the Python side and have the GUI update?

    Why would you want to? The nib loader set it to a control; if you set the variable, you would lose the control.

    To set the value of the control, send it a setStringValue_ (or similar) message.