问题
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