Re: [pygtk] Best pattern for keyboard accelerators in dialog
On Fri, Jan 26, 2007 at 08:49:51AM +, 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 ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Best pattern for keyboard accelerators in dialog
Hi I have a Window that has a number of widgets placed in it, including a TreeView, a Frame (containing more widgets), buttons etc. The Frame contains a table with Labels, CheckButton and Edit widgets. 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. I would really like to keep the handling of these accelerators inside the abstractions of the sub-widgets. The Frame is implemented as a subclass of gtkFrame and I want to be able to plug in different Frames into the main Window with different keybindings. Is there a good pattern for coding this type of thing or an example of another app that I can take a look at? Regards Richard ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Best pattern for keyboard accelerators in dialog
Am Freitag, 26. Januar 2007 09:49 schrieb Richard Taylor: Hi I have a Window that has a number of widgets placed in it, including a TreeView, a Frame (containing more widgets), buttons etc. Hi, does this help you? http://www.pygtk.org/pygtk2tutorial/sec-WidgetAccelerators.html 18.3. Widget Accelerators The following methods: widget.add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) widget.remove_accelerator(accel_group, accel_key, accel_mods) add and remove accelerators from a gtk.AcceleratorGroup that must be attached to the top level widget to handle the accelerators. The accel_signal is a signal that is valid for the widget to emit. The accel_key is a keyboard key to use as the accelerator. The accel_mods are modifiers to add to the accel_key (e.g. Shift, Control, etc.): SHIFT_MASK LOCK_MASK CONTROL_MASK MOD1_MASK MOD2_MASK MOD3_MASK MOD4_MASK MOD5_MASK BUTTON1_MASK BUTTON2_MASK BUTTON3_MASK BUTTON4_MASK BUTTON5_MASK RELEASE_MASK The accel_flags set options about how the accelerator information is displayed. Valid values are: ACCEL_VISIBLE # display the accelerator key in the widget display ACCEL_LOCKED # do not allow the accelerator display to change An accelerator group is created by the function: accel_group = gtk.AccelGroup() The accel_group is attached to a top level widget with the following method: window.add_accel_group(accel_group) An example of adding an accelerator: menu_item.add_accelerator(activate, accel_group, ord('Q'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Best pattern for keyboard accelerators in dialog
On Friday 26 January 2007 09:58, Thomas Guettler wrote: Am Freitag, 26. Januar 2007 09:49 schrieb Richard Taylor: Hi I have a Window that has a number of widgets placed in it, including a TreeView, a Frame (containing more widgets), buttons etc. Hi, does this help you? http://www.pygtk.org/pygtk2tutorial/sec-WidgetAccelerators.html 18.3. Widget Accelerators The following methods: widget.add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) widget.remove_accelerator(accel_group, accel_key, accel_mods) add and remove accelerators from a gtk.AcceleratorGroup that must be attached to the top level widget to handle the accelerators. The accel_signal is a signal that is valid for the widget to emit. The accel_key is a keyboard key to use as the accelerator. The accel_mods are modifiers to add to the accel_key (e.g. Shift, Control, etc.): SHIFT_MASK LOCK_MASK CONTROL_MASK MOD1_MASK MOD2_MASK MOD3_MASK MOD4_MASK MOD5_MASK BUTTON1_MASK BUTTON2_MASK BUTTON3_MASK BUTTON4_MASK BUTTON5_MASK RELEASE_MASK The accel_flags set options about how the accelerator information is displayed. Valid values are: ACCEL_VISIBLE # display the accelerator key in the widget display ACCEL_LOCKED # do not allow the accelerator display to change An accelerator group is created by the function: accel_group = gtk.AccelGroup() The accel_group is attached to a top level widget with the following method: window.add_accel_group(accel_group) An example of adding an accelerator: menu_item.add_accelerator(activate, accel_group, ord('Q'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) ___ I had read this documentation but I could not work out the correct pattern for making use of it. So the principle is to use 'add_accelerator' on each of the widgets that I want to be activated by keypress and then somehow agregate the accel_groups up to the top level widget? Or is it better to construct the accel_group in the top level window and pass it in to the constructor of all the sub widgets, using it in the calls to add_accelerator on each of the sub widgets? Does anyone have an example of doing this? Thanks again. Richard ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/