I am creating an application for the Ubuntu App Showdown in Python + Gtk with quickly. I am calling it Discvur. I would have liked to include some keyboard shortcuts.
Searching the web, I found this page about AccelGroup and this page about gtk_widget_add_accelerator but I don't understand how to start with it. Could you tell me how I would define an appropriate signal and then use it in my application?
Here's some bits of code from one of my Python + Gtk apps, further extended according to the comments to this answer:
Here is the code that finally worked. As it depends highly on my development environment Quickly + Glade + Python + Gtk, I make it an independent answer. Bryce's answer helped a lot, and so did my exchanges with aking1012.
The actual code, in a text editor:
In Glade, I created a GtkEntry called "entry1" in my window called "discvur_window". In the 'Signals' tab, I gave the signal "backspace" a handler called "on_erasing".
Now, hitting Backspace or Ctrl+B makes the terminal print "It works.".
I've repackaged the given answers in this thread into a standalone example:
Note: The default signal is
clicked
, notactivate
because Applications should never connect to the::activate
signal, but use the Gtk.Button::clicked
signal.