[pygtk] Best pattern for keyboard accelerators in dialog

David M. Cook dave at davidcook.org
Mon Jan 29 12:19:30 WST 2007


On Fri, Jan 26, 2007 at 08:49:51AM +0000, Richard Taylor wrote:

> I would like to provide keyboard accelerators that move the focus to the 
> appropriate Widget. I want to underline a letter in each label and link 
> Alt-<letter> to switch to the Edit widget alongside the Label. I would like 
> these accelerators to work regardless of which widget has the focus.

Easiest is

label.set_use_underline(True)
label.set_mnemonic_widget(widget)

but that's global. I don't know of a way to make that only
work in a sub-widget.

http://pygtk.org/docs/pygtk/class-gtklabel.html#method-gtklabel--set-mnemonic-widget

Dave Cook


More information about the pygtk mailing list