检测GUI中的特定按键 [英] Detect specific keypresses in GUI
问题描述
我在Gtk / Python中寻找一种方法来让应用程序监听按键,当某些特殊按键被按下时,执行一个操作(重新创建一个带有不同标签的菜单,因为它是一个appindicator)。尽管如此,我还是无法找到办法。如果有人能够提供帮助,我会很感激。 您可能需要处理key-press-event(也可能key-release-event)的GtkWidget。 PyGtk了解 。
它应该位于某个窗口窗口小部件的内部,因此您可能需要使用 GtkEventBox 作为容器。
I'm looking for a way in Gtk/Python to have an app listen for keypresses and when some of the special keys are pressed, perform an action (recreate a menu with different labels, since it's an appindicator). I can't really find a way to do it though. If anyone is able to help, I'd be thankful.
You probably need to handle the "key-press-event" (and probably also "key-release-event") of GtkWidget. PyGtk knows about it.
It should be inside some "windowing" widget, so you may need to use GtkEventBox as a container.
这篇关于检测GUI中的特定按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!