gtk.AccelGroup — a group of accelerators for a Window hierarchy
class gtk.AccelGroup( |
Functionsdef gtk.accelerator_valid(
keyval
,modifiers
)def gtk.accelerator_parse(
accelerator
)def gtk.accelerator_name(
accelerator_key
,accelerator_mods
)def gtk.accelerator_set_default_mod_mask(
default_mod_mask
)def gtk.accelerator_get_default_mod_mask()
def gtk.accelerator_get_label(
accelerator_key
,accelerator_mods
)def gtk.accel_groups_from_object(
object
)
|
def callback( | |
def callback( |
A 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 Ctrl+Q might appear alongside the → 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.
def lock()
The 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.
def unlock()
The unlock
() method undoes the last
call to gtk.AccelGroup.lock
()
for this accelerator group.
def connect_group(accel_key
, accel_mods
, accel_flags
, callback
)
| key value of the accelerator |
| modifier combination of the accelerator |
| a flag mask to configure this accelerator |
| a function or method to be executed upon accelerator activation |
This 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
()
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 GDK Modifier Constants. 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.
def connect_by_path(accel_path
, callback
)
| path used for determining key and modifiers. |
| function or method to be executed upon accelerator activation |
This method is available in PyGTK 2.4 and above
The 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
.
def disconnect_key(accel_key
, accel_mods
)
| key value of the accelerator |
| modifier combination of the accelerator |
Returns : | True if there was an
accelerator which was removed, False
otherwise |
The disconnect
() method removes a
previously installed accelerator specified by
accel_key
and accel_mods
from
the accelerator group.
def get_is_locked()
Returns : | 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().
def get_modifier_mask()
Returns : | 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.
def gtk.accelerator_valid(keyval
, modifiers
)
| a key value |
| a modifier mask |
Returns : | True if the accelerator is
valid |
The 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 Control+a
accelerator. The value of modifiers
is a combination
of the GDK Modifier Constants.
def gtk.accelerator_parse(accelerator
)
| a string representing an accelerator |
Returns : | a 2-tuple containing the keyval and modifier mask of the accelerator |
The 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.
def gtk.accelerator_name(
)
| a key value |
| a modifier mask |
Returns : | a string representing the accelerator or
None if not a valid accelerator |
The 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".
def gtk.accelerator_set_default_mod_mask(default_mod_mask
)
| the new default accelerator modifier mask |
The 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 GDK Modifier Constants.
def gtk.accelerator_get_default_mod_mask()
Returns : | the default accelerator modifier mask |
The 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.
def gtk.accelerator_get_label(accelerator_key
, accelerator_mods
)
| a key value |
| a modifier mask |
Returns : | a string representing the accelerator |
This 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 GDK Modifier Constants.
def gtk.accel_groups_from_object(object
)
| a GObject usually a gtk.Window |
This 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
.
def callback(accelgroup
, acceleratable
, accel_key
, accel_mods
, user_param1
, ...
)
| the accelgroup that received the signal |
| the object that the accelerator is associated with |
| the accelerator key value |
| the accelerator modifiers |
| the first user parameter (if any) specified
with the gobject.GObject.connect () |
| additional user parameters (if any) |
Returns : | True if the accelerator
was handled |
The "accel-activate" signal is emitted when an accelerator is activated.
def callback(accelgroup
, accel_key
, accel_mods
, closure
, user_param1
, ...
)
| the accelgroup that received the signal |
| the key value of the accelerator |
| the modifiers of the accelerator |
| the closure of the accelerator |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
The "accel-changed" signal is emitted when an accelerator is added or removed from an accelerator group.