Python gtk:如何检查组合框是否打开?

发布于 2025-01-07 18:02:53 字数 485 浏览 6 评论 0原文

我正在研究机器的图形用户界面。它在窗口中使用组合框,可以在主线程中、主循环之外随时重绘(使用 gtk-lock 内的idle_add 函数)。当按下机器上的某个按钮(真实的按钮,而不是小部件)时,就会发生这种情况。如果在组合框打开时发生这种情况,我会收到 Gtk 警告:断言“WIDGET REALIZED FOR EVENT”失败,并且我的程序挂起。

我尝试添加代码:

    combo.set_active(-1)
    while gtk.events_pending():
          gtk.main_iteration()

但这并没有解决问题。

我一直在寻找像combo.is_open()或combo.close()这样的函数,但它们似乎不存在。与组合相关的信号有“更改”、“移动活动”、“弹出”和“弹出”,但第一个信号仅在组合中选择文本时发送,其他信号是键绑定信号。

有什么方法可以检查组合是否打开(已被选择)?

I am working on the graphical user interface of a machine. It uses comboboxes in a window that can be redrawn at any time in the main thread, outside the main loop (using the idle_add function inside the gtk-lock). This will happen when a certain button -a real one, not a widget- is pressed on the machine. If this happens while the combobox is open, I get a Gtk-Warning: assertion 'WIDGET REALIZED FOR EVENT' failed and my program hungs.

I tried to add the code:

    combo.set_active(-1)
    while gtk.events_pending():
          gtk.main_iteration()

but this didn't solve the problem.

I have been looking for functions like combo.is_open() or combo.close() but they don't seem to exist. The signals related to a combo are 'changed','move-active','pop-up' and 'pop-down' but the first is only sent when a text is selected in the combo and the other ones are keybinding signals.

Is there any way to check if a combo is open (has been selected) ?

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

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

发布评论

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

评论(1

千纸鹤 2025-01-14 18:02:53

使用 popup-shown属性。

该文档甚至告诉您连接到 notify::popup-shown 这听起来正是您所需要的。

Use the popup-shown property.

The documentation even tells you to connect to notify::popup-shown which sounds like just what you need.

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