Functions

  bind (keystring, handler, *user_data)
  get_current_event_time ()
  init ()
  set_use_cooked_accelerators (use_cooked)
  supported ()
  unbind (keystring)

Details

Keybinder.bind(keystring, handler, *user_data)
Parameters:
  • keystring (str) – an accelerator description (gtk_accelerator_parse() format)
  • handler (Keybinder.Handler) – callback function
  • user_data (object or None) – data to pass to handler
Returns:

True if the accelerator could be grabbed

Return type:

bool

Grab a key combination globally and register a callback to be called each time the key combination is pressed.

New in version 0.3.0.

Keybinder.get_current_event_time()
Returns:the current event timestamp
Return type:int
Keybinder.init()

Initialize the keybinder library.

This function must be called after initializing GTK, before calling any other function in the library. Can only be called once.

Keybinder.set_use_cooked_accelerators(use_cooked)
Parameters:use_cooked (bool) – if False disable cooked accelerators

“Cooked” accelerators use symbols produced by using modifiers such as shift or altgr, for example if “!” is produced by “Shift+1”.

If cooked accelerators are enabled, use “<Ctrl>exclam” to bind “Ctrl+!” If disabled, use “<Ctrl><Shift>1” to bind “Ctrl+Shift+1”. These two examples are not equal on all keymaps.

The cooked accelerator keyvalue and modifiers are provided by the function gdk_keymap_translate_keyboard_state()

Cooked accelerators are useful if you receive keystrokes from GTK to bind, but raw accelerators can be useful if you or the user inputs accelerators as text.

Default: Enabled. Should be set before binding anything.

Keybinder.supported()
Returns:True if keybindings are supported
Return type:bool
Keybinder.unbind(keystring)
Parameters:keystring (str) – an accelerator description (gtk_accelerator_parse() format)

Unregister all previously bound callbacks for this keystring.

New in version 0.3.0.