如何将 TextField 绑定到 IBOutlet()?

发布于 2024-08-05 19:12:38 字数 282 浏览 2 评论 0原文

我试图弄清楚如何以编程方式更新 NSTextField 。

我已经弄清楚如何从 Python 获取文本字段的当前值:

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

How do I set the value of myVar from the Python side and have the GUI update?我想要某种双向绑定(例如 Flex 中的 {myVAR})。

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2024-08-12 19:12:38

如何从 Python 端设置 myVar 的值并更新 GUI?

你为什么想要这么做?笔尖加载器将其设置为控件;如果你设置了变量,你就会失去控制。

要设置控件的值,请向其发送 setStringValue_ (或类似)消息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文