输入通知事件信号无法使用gtk.ToolButton [英] Enter-Notify-Event Signal not working on gtk.ToolButton
问题描述
现在,到实际问题...
我的应用程序中有一个工具栏(Python 2.7,PyGTK),其上有一些gtk.ToolButton对象。这些功能很好。我有工作的点击事件与他们绑定。
但是,我还需要将它们连接到enter-notify-event和leave-notify-event信号,所以我可以在状态栏中显示按钮的功能。
这是我的代码。我没有收到任何错误,但状态栏消息未显示:
new_tb = gtk.ToolButton(gtk.STOCK_NEW )
toolbar.insert(new_tb,-1)
new_tb.show()
new_tb.connect(clicked,new_event)
new_tb.connect(enter-notify-事件,status_push,创建一个新的空项目)
new_tb.connect(leave-notify-event,status_pop)
我知道问题不在于status_push和status_pop事件,因为我将所有的gtk.MenuItem对象连接到他们,并且他们在游泳中工作。 p>
我知道gtk.ToolButton对象在Widgets类中,所以enter-notify-event和leave-notify-event应该在技术上有效。我唯一的猜测是,这个特定的对象不会发出除点击之外的任何信号,因此我必须把它们放在一个gtk.EventBox中。
什么我在这里做错了吗?谢谢提前!
看来,基于实验和证据,这在PyGtk 2.24中是不可能的。
On a happy (if not irrevelent) note, this is the absolute last obstacle in this particular project. If I fix this, I have my first significant dot release (1.0), and the project will be going public. Thanks to everyone here on SO for helping me through this project, and my other two (the answers help across the board, as they should).
Now, to the actual question...
I have a toolbar in my application (Python 2.7, PyGTK) which has a number of gtk.ToolButton objects on it. These function just fine. I have working "clicked" events tied to them.
However, I need to also connect them to "enter-notify-event" and "leave-notify-event" signals, so I can display the button's functions in the statusbar.
This is the code I have. I am receiving no errors, and yet, the status bar messages are not appearing:
new_tb = gtk.ToolButton(gtk.STOCK_NEW)
toolbar.insert(new_tb, -1)
new_tb.show()
new_tb.connect("clicked", new_event)
new_tb.connect("enter-notify-event", status_push, "Create a new, empty project.")
new_tb.connect("leave-notify-event", status_pop)
I know the issue is not with the "status_push" and "status_pop" events, as I've connected all my gtk.MenuItem objects to them, and they work swimmingly.
I know that gtk.ToolButton objects are in the Widgets class, so "enter-notify-event" and "leave-notify-event" SHOULD technically work. My only guess is that this particular object does not emit any signals other than "clicked", and thus I'd have to put each in a gtk.EventBox.
What am I doing wrong here? How do I fix this?
Thanks in advance!
It appears, based on experimentation and evidence, this is impossible in PyGtk 2.24.
这篇关于输入通知事件信号无法使用gtk.ToolButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!