gtk.AccelGroupa group of accelerators for a Window hierarchySynopsisgtk.AccelGroupgobject.GObjectgtk.AccelGrouplockunlockconnectaccel_keyaccel_modsaccel_flagscallbackconnect_groupaccel_keyaccel_modsaccel_flagscallbackconnect_by_pathaccel_pathcallbackdisconnect_keyaccel_keyaccel_modsget_is_lockedget_modifier_maskFunctionsgtk.accelerator_validkeyvalmodifiersgtk.accelerator_parseacceleratorgtk.accelerator_nameaccelerator_keyaccelerator_modsgtk.accelerator_set_default_mod_maskdefault_mod_maskgtk.accelerator_get_default_mod_maskgtk.accelerator_get_labelaccelerator_keyaccelerator_modsgtk.accel_groups_from_objectobjectAncestry
+-- gobject.GObject
+-- gtk.AccelGroup
gtk.AccelGroup Properties
"is-locked"ReadTrue if the accel group is locked, False otherwise.
"modifier-mask"Read
The modifier mask of the accel group.
gtk.AccelGroup Signal Prototypes"accel-activate"callbackaccelgroupacceleratableaccel_keyaccel_modsuser_param1..."accel-changed"callbackaccelgroupaccel_keyaccel_modsclosureuser_param1...DescriptionA gtk.AccelGroup
object groups all the accelerators for the associated window hierarchy
(either gtk.Window (or a
descendant) or gtk.MenuShell (or
a descendant)). Once the gtk.AccelGroup
is associated with a window or menu (using gtk.Window.add_accel_group()
or gtk.Menu.set_accel_group()),
accelerators can be added to the widget or one of its children by using
gtk.Widget.add_accelerator()
. Accelerators can also be added by using a gtk.ItemFactory.Note that accelerators are different from mnemonics. Accelerators
are shortcuts for activating a menu item; they appear alongside the menu
item they're a shortcut for. For example
CtrlQ might appear alongside the
FilesQuit menu item. Mnemonics are shortcuts for GUI elements such
as text entries or buttons; they appear as underlined characters. Of course,
menu items can have both accelerators and mnemonics.Constructorgtk.AccelGroupReturns :an AccelGroup objectCreates a new gtk.AccelGroup
object.Methodsgtk.AccelGroup.locklockThe lock() method locks the accelerator
group. preventing its accelerators from being changed during runtime. Refer
to gtk.accel_map_change_entry()
about runtime accelerator changes.If called more than once, the accelerator group remains locked
until gtk.AccelGroup.unlock()
has been called an equivalent number of times.gtk.AccelGroup.unlockunlockThe unlock() method undoes the last
call to gtk.AccelGroup.lock()
for this accelerator group.gtk.AccelGroup.connect_groupconnect_groupaccel_keyaccel_modsaccel_flagscallbackaccel_key :key value of the
acceleratoraccel_mods :modifier combination of the
acceleratoraccel_flags :a flag mask to configure this
acceleratorcallback :a function or method to be executed upon
accelerator activationThis method is available in PyGTK 2.2 as
connect() and was changed in PyGTK 2.4 and
above to connect_group() to avoid conflict
with the gobject.GObject.connect()
method.The connect_group() method installs an
accelerator in the accelerator group. When the accelerator group is being
activated, the function (or method) specified by
callback will be invoked if the accelerator key and
modifier key match those specified by accel_key and
accel_mods.The value of modifier is a combination of
the . accel_flags
is a combination of gtk.ACCEL_VISIBLE and
gtk.ACCEL_LOCKED.The callback function is defined as:
def callback(accel_group, acceleratable, keyval, modifier)
where accel_group is the accelerator
group, acceleratable is the object that the
accel_group is attached to (e.g. a gtk.Window),
keyval is the accelerator key and
modifier is the key
modifier. callback returns True if
the accelerator was handled by callback.Due to implementation details, a single function or method
can only be connected to one accelerator group.gtk.AccelGroup.connect_by_pathconnect_by_pathaccel_pathcallbackaccel_path :path used for determining key and
modifiers.callback :function or method to be executed upon accelerator
activationThis method is available in PyGTK 2.4 and aboveThe connect_by_path() method installs
an accelerator in the accelerator group, using an accelerator path to look
up the appropriate key and modifiers (see the function gtk.accel_map_add_entry()). When
the accelerator group is being activated, the function (or method) specified
by callback will be invoked if the
accel_key and accel_mods that
cause the activation match the key and modifiers for the accelerator path
specified by accel_path.The callback function is defined as:
def callback(accel_group, acceleratable, keyval, modifier)
where accel_group is the accelerator
group, acceleratable is the object that the
accel_group is attached to (e.g. a gtk.Window),
keyval is the accelerator key and
modifier is the key
modifier. callback returns True if
the accelerator was handled by callback.gtk.AccelGroup.disconnect_keydisconnect_keyaccel_keyaccel_modsaccel_key :key value of the
acceleratoraccel_mods :modifier combination of the
acceleratorReturns :True if there was an
accelerator which was removed, False
otherwiseThe disconnect() method removes a
previously installed accelerator specified by
accel_key and accel_mods from
the accelerator group.gtk.AccelGroup.get_is_lockedget_is_lockedReturns :True if there are 1 or more locks
on the accel_group, False otherwise. This method is available in PyGTK 2.14 and above.
The get_is_locked() method returns the locked status.
Locks are added and removed using
lock() and
lock().
gtk.AccelGroup.get_modifier_maskget_modifier_maskReturns :the modifier mask for this accel group.This method is available in PyGTK 2.14 and above.
The get_modifier_mask() method gets a
GdkModifierType representing the mask for this accel_group.
For example, gtk.gdk.CONTROL_MASK, gtk.gdk.SHIFT_MASK, etc.
Functionsgtk.accelerator_validgtk.accelerator_validkeyvalmodifierskeyval :a key valuemodifiers :a modifier maskReturns :True if the accelerator is
validThe gtk.accelerator_valid() function
returns True if the specified
keyval and modifiers
constitute a valid keyboard accelerator. For example, the
ord('a') keyval plus
gtk.gdk.CONTROL_MASK is valid - this is a Controla
accelerator. The value of modifiers is a combination
of the .gtk.accelerator_parsegtk.accelerator_parseacceleratoraccelerator :a string representing an
acceleratorReturns :a 2-tuple containing the keyval and modifier
mask of the acceleratorThe gtk.accelerator_parse() function parses
the specified accelerator string and returns a
2-tuple containing the keyval and modifier mask corresponding to
accelerator. The format looks like "<Control>a" or
"<Shift><Alt>F1" or "<Release>z" (the last one is for key release). The
parser is fairly liberal and allows lower or upper case, and also
abbreviations such as "<Ctl>" and "<Ctrl>". If the parse fails, the tuple
values will both be 0 (zero). See the gtk.accelerator_valid()
function for more details.gtk.accelerator_namegtk.accelerator_nameaccelerator_key :a key valueaccelerator_mods :a modifier maskReturns :a string representing the accelerator or
None if not a valid acceleratorThe gtk.accelerator_name() function
converts the accelerator keyval and modifier mask (specified by
accelerator_key and
accelerator_mods) into a string parseable by the
gtk.accelerator_parse()
function. For example, if you pass in ord('q') and
gtk.gdk.CONTROL_MASK, this function returns
"<Control>q".gtk.accelerator_set_default_mod_maskgtk.accelerator_set_default_mod_maskdefault_mod_maskdefault_mod_mask :the new default accelerator modifier
maskThe gtk.accelerator_set_default_mod_mask()
function sets the modifiers (specified by
default_mod_mask) that will be considered significant
for keyboard accelerators. The default mod mask is
gtk.gdk.CONTROL_MASK |
gtk.gdk.SHIFT_MASK |
gtk.gdk.MOD1_MASK, that is, Control,
Shift, and Alt. Other modifiers will by
default be ignored by gtk.AccelGroup.
You must include at least the three default modifiers in any value you pass
to this function. The default mod mask should be changed on application
startup, before using any accelerator groups. The value of
default_mod_mask is a combination of the .gtk.accelerator_get_default_mod_maskgtk.accelerator_get_default_mod_maskReturns :the default accelerator modifier
maskThe gtk.accelerator_get_default_mod_mask()
function returns the default accelerator modifier mask as set by the gtk.accelerator_set_default_mod_mask()
function. See the gtk.accelerator_set_default_mod_mask()
function for more detail on modifier masks.gtk.accelerator_get_labelgtk.accelerator_get_labelaccelerator_keyaccelerator_modsaccelerator_key :a key valueaccelerator_mods :a modifier maskReturns :a string representing the
acceleratorThis function is available in PyGTK 2.6 and above.The gtk.accelerator_get_label() function
converts the accelerator keyval and modifier mask specified by
accelerator_key and
accelerator_mods respectively into a string which can
be used to represent the accelerator to the user. The value of
accelerator_mods is a combination of the .gtk.accel_groups_from_objectgtk.accel_groups_from_objectobjectobject :a GObject usually a gtk.WindowThis function is available in PyGTK 2.4 and above.The gtk.accel_groups_from_object() function
returns a list of all the gtk.AccelGroup
objects attached to the object specified by
object.SignalsThe "accel-activate" gtk.AccelGroup Signalcallbackaccelgroupacceleratableaccel_keyaccel_modsuser_param1...accelgroup :the accelgroup that received the
signalacceleratable :the object that the accelerator is associated
withaccel_key :the accelerator key valueaccel_mods :the accelerator modifiersuser_param1 :the first user parameter (if any) specified
with the gobject.GObject.connect()
method... :additional user parameters (if
any)Returns :True if the accelerator
was handledThe "accel-activate" signal is emitted when an accelerator is
activated.The "accel-changed" gtk.AccelGroup Signalcallbackaccelgroupaccel_keyaccel_modsclosureuser_param1...accelgroup :the accelgroup that received the
signalaccel_key :the key value of the
acceleratoraccel_mods :the modifiers of the
acceleratorclosure :the closure of the
acceleratoruser_param1 :the first user parameter (if any) specified
with the connect()
method... :additional user parameters (if
any)The "accel-changed" signal is emitted when an accelerator is
added or removed from an accelerator group.