Python gtk:如何检查组合框是否打开?
我正在研究机器的图形用户界面。它在窗口中使用组合框,可以在主线程中、主循环之外随时重绘(使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
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.