|
class gtk.gdk.Keymap( |
Functionsdef gtk.gdk.keymap_get_default()
def gtk.gdk.keymap_get_for_display(
display
)def gtk.gdk.keyval_name(
keyval
)def gtk.gdk.keyval_from_name(
keyval_name
)def gtk.gdk.keyval_convert_case(
symbol
)def gtk.gdk.keyval_to_upper(
keyval
)def gtk.gdk.keyval_to_lower(
keyval
)def gtk.gdk.keyval_is_upper(
keyval
)def gtk.gdk.keyval_is_lower(
keyval
)def gtk.gdk.keyval_to_unicode(
keyval
)def gtk.gdk.unicode_to_keyval(
wc
)
def callback( | |
def callback( |
A gtk.gdk.Keymap
defines the translation from keyboard state (including a hardware key, a
modifier mask, and active keyboard group) to a keyval. This translation has
two phases. The first phase is to determine the effective keyboard group and
level for the keyboard state; the second phase is to look up the
keycode/group/level triplet in the keymap and see what keyval it corresponds
to. One gtk.gdk.Keymap
object exists for each user display. PyGTK
supports only
one display, so gtk.gdk.keymap_get_default()
()
returns the singleton gtk.gdk.Keymap
.
A keymap is a mapping from a Keymap key to key values. You can think of a Keymap key as a representation of a symbol printed on a physical keyboard key. That is, it contains three pieces of information. First, it contains the hardware keycode; this is an identifying number for a physical key. Second, it contains the level of the key. The level indicates which symbol on the key will be used, in a vertical direction. So on a standard US keyboard, the key with the number "1" on it also has the exclamation point ("!") character on it. The level indicates whether to use the "1" or the "!" symbol. The letter keys are considered to have a lowercase letter at level 0, and an uppercase letter at level 1, though only the uppercase letter is printed. Third, the Keymap key contains a group; groups are not used on standard US keyboards, but are used in many other countries. On a keyboard with groups, there can be 3 or 4 symbols printed on a single key. The group indicates movement in a horizontal direction. Usually groups are used for two different languages. In group 0, a key might have two English characters, and in group 1 it might have two Hebrew characters. The Hebrew characters will be printed on the key next to the English characters.
def lookup_key(keycode
, group
, level
)
| the hardware keycode. |
| the key group |
| the key level |
Returns : | a keyval, or 0 if none was mapped to the
(keycode , group ,
level ) triplet. |
This method is available in PyGTK 2.4 and above.
The lookup_key
() method returns the
keyval mapped to the specified (keycode
,
group
, level
) triplet. This
method returns 0 if no keyval is found. For normal user input, you want to
use the translate_keyboard_state()
method instead of this method, since the effective group or level may not be
the same as the current keyboard state.
The parameters to this method are:
| the hardware keycode. This is an identifying number for a physical key. |
| indicates movement in a horizontal direction. Usually groups are used for two different languages. In group 0, a key might have two English characters, and in group 1 it might have two Hebrew characters. The Hebrew characters will be printed on the key next to the English characters. |
| indicates which symbol on the key will be used, in a vertical direction. So on a standard US keyboard, the key with the number "1" on it also has the exclamation point ("!") character on it. The level indicates whether to use the "1" or the "!" symbol. The letter keys are considered to have a lowercase letter at level 0, and an uppercase letter at level 1, though only the uppercase letter is printed. |
def translate_keyboard_state(keycode
, state
, group
)
| a keycode |
| a modifier state |
| an active keyboard group |
Returns : | a 4-tuple containing the keyval, the effective group, the level and the modifiers that were used to determine the group or level |
This method is available in PyGTK 2.4 and above.
The translate_keyboard_state
() method
translates the contents of a keyboard gtk.gdk.Event
(specified by keycode
,
state
and group
) into a
keyval, effective group, level and consumed modifiers that affected
the translation (and are unavailable for application use) which are
returned in a 4-tuple. See the lookup_key
()
method for an explanation of groups and levels. The effective group is
the group that was actually used for the translation; some keys such
as Enter are not affected by the active keyboard
group. The level is derived from state
. For
convenience, the keyboard gtk.gdk.Event
already contains the translated keyval, so this method isn't as useful
as you might think.
The value of state
or the consumed
modifiers is a combination of the GDK Modifier Constants.
The consumed modifiers are modifiers that should be masked out
from state
when comparing this key press to a hot
key. For instance, on a US keyboard, the plus symbol is
shifted, so when comparing a key press to a
Control+plus
accelerator Shift should be masked out. For
example:
# We want to ignore irrelevant modifiers like ScrollLock ALL_ACCELS_MASK = (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK | gtk.gdk.MOD1_MASK) keyval, egroup, level, consumed = keymap.translate_keyboard_state( event.hardware_keycode, event.state, event.group) if (keyval == gtk.keysyms.plus and (event.state & ~consumed & ALL_ACCELS_MASK) == gtk.gdk.CONTROL_MASK): # Control was pressed
Note that most keys that are affected by the
Shift key will have gtk.gdk.SHIFT_MASK
part of the consumed modifiers (e.g. Control+Shift+Tab).
All single modifier combinations that could affect the key for
any combination of modifiers will be returned in consumed_modifiers.
Multi-modifier combinations are returned only when actually found in
state
. When you store accelerators, you should always
store them with consumed modifiers removed. Store <Control>plus, not
<Control><Shift>plus,
def get_entries_for_keyval(keyval
)
| a keyval, such as GDK_a ,
GDK_Up , GDK_Return ,
etc. |
Returns : | a tuple containing 3-tuple containing a keycode,
a group and a level that will generate
keyval . |
This method is available in PyGTK 2.4 and above.
The get_entries_for_keyval
() method
returns a tuple of (keycode, group, level) 3-tuples that will generate
keyval
. Groups and levels are two kinds of keyboard
mode; in general, the level determines whether the top or bottom symbol on a
key is used, and the group determines whether the left or right symbol is
used. On US keyboards, the shift key changes the keyboard level, and there
are no groups. A group switch key might convert a keyboard between Hebrew to
English modes, for example, the gtk.gdk.KEY_PRESS
and
gtk.gdk.KEY_RELEASE
gtk.gdk.Event
objects
contain a group
attribute that indicates the active
keyboard group. The level is computed from the modifier mask.
def get_entries_for_keycode(hardware_keycode
)
| a keycode |
Returns : | a tuple containing 4-tuples: (keyval, keycode, group, level) |
This method is available in PyGTK 2.4 and above.
The get_entries_for_keycode
() method
returns a tuple containing 4-tuples with: the keyvals bound to
hardware_keycode
, the keycode, the group and the
level. When a keycode is pressed by the user, the keyval from this list of
entries is selected by considering the effective keyboard group and
level. See the translate_keyboard_state()
method for more information.
def gtk.gdk.keymap_get_default()
Returns : | the default gdk keymap for the display. |
The gtk.gdk.keymap_get_default
() function
returns the default gtk.gdk.Keymap
for
the display.
def gtk.gdk.keymap_get_for_display(display
)
| a gtk.gdk.Display |
Returns : | the keymap for
display . |
This function is available in PyGTK 2.2 and above.
The gtk.gdk.keymap_get_for_display
()
function returns the gtk.gdk.Keymap
for
the gtk.gdk.Display
specified by display
.
def gtk.gdk.keyval_name(keyval
)
| a key value |
Returns : | a string containing the name of the key, or None if keyval is not a valid key. |
The gtk.gdk.keyval_name
() function converts
the key value specified by keyval
into a symbolic
name.
def gtk.gdk.keyval_from_name(keyval_name
)
| a key name |
Returns : | the corresponding key value or 0 if the key name is not a valid key. |
The gtk.gdk.keyval_from_name
() function
converts the key name specified by keyval_name
to a
key value.
def gtk.gdk.keyval_convert_case(symbol
)
| a keyval |
Returns : | a 2-tuple containing the lowercase and
uppercase versions of
symbol |
This function is available in PyGTK 2.4 and above.
The gtk.gdk.keyval_convert_case
() function
returns the lowercase and uppercase versions of the keyval specified by
symbol
.
def gtk.gdk.keyval_to_upper(keyval
)
| a key value. |
Returns : | the upper case form of keyval, or keyval itself if it is already in upper case or it is not subject to case conversion. |
The gtk.gdk.keyval_to_upper
() function
converts the key value specified by keyval
to upper
case, if applicable.
def gtk.gdk.keyval_to_lower(keyval
)
| the key value |
Returns : | the lower case form of keyval, or keyval itself if it is already in lower case or it is not subject to case conversion. |
The gtk.gdk.keyval_to_lower
() function
converts the key value specified by keyval
to lower
case, if applicable.
def gtk.gdk.keyval_is_upper(keyval
)
| the key value |
Returns : | True if
keyval is in upper case or if keyval is not subject
to case conversion. |
The gtk.gdk.keyval_is_upper
() function
returns True
if the key value specified by
keyval
is in upper case or not subject to case
conversion.
def gtk.gdk.keyval_is_lower(keyval
)
| the key value |
Returns : | True if
keyval is in lower case, or if
keyval is not subject to case
conversion. |
The gtk.gdk.keyval_is_lower
() function
returns True
if the key value specified by
keyval
is in lower case or is not subject to case
conversion.
def gtk.gdk.keyval_to_unicode(keyval
)
| the key value |
Returns : | the corresponding unicode character, or 0 if there is no corresponding character. |
The gtk.gdk.keyval_to_unicode
() function
converts the key value specified by keyval
to the
corresponding ISO10646 (Unicode) character.
def gtk.gdk.unicode_to_keyval(wc
)
| a ISO10646 encoded (unicode) character |
Returns : | the corresponding key value, if one exists. or,
if there is no corresponding symbol, wc |
0x01000000 |
The gtk.gdk.unicode_to_keyval
() function
converts the ISO10646 (unicode) character specified by
wc
to a key value.
def callback(gdkkeymap
, user_param1
, ...
)
| the gdkkeymap that received the signal |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
The "direction-changed" signal is emitted when the pango text
direction of gdkkeymap
is changed
def callback(gdkkeymap
, user_param1
, ...
)
| the gdkkeymap that received the signal |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
This signal is available in GTK+ 2.2 and above.
The "keys-changed" signal is emitted when the mapping
represented by keymap
changes.
© manpagez.com 2000-2024 Individual documents may contain additional copyright information.