Detect specific keypresses in GUI

那年仲夏 提交于 2019-12-31 07:11:30

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13713347/detect-specific-keypresses-in-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!