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/

Reply via email to