Shortcut#

class Shortcut(**properties: Any)#

Superclasses: Object

A GtkShortcut describes a keyboard shortcut.

It contains a description of how to trigger the shortcut via a ShortcutTrigger and a way to activate the shortcut on a widget via a ShortcutAction.

The actual work is usually done via ShortcutController, which decides if and when to activate a shortcut. Using that controller directly however is rarely necessary as various higher level convenience APIs exist on GtkWidget’s that make it easier to use shortcuts in GTK.

GtkShortcut does provide functionality to make it easy for users to work with shortcuts, either by providing informational strings for display purposes or by allowing shortcuts to be configured.

Constructors#

class Shortcut
classmethod new(trigger: ShortcutTrigger | None = None, action: ShortcutAction | None = None) Shortcut#

Creates a new GtkShortcut that is triggered by trigger and then activates action.

Parameters:
  • trigger – The trigger that will trigger the shortcut

  • action – The action that will be activated upon triggering

Methods#

class Shortcut
get_action() ShortcutAction | None#

Gets the action that is activated by this shortcut.

get_arguments() Variant | None#

Gets the arguments that are passed when activating the shortcut.

get_trigger() ShortcutTrigger | None#

Gets the trigger used to trigger self.

set_action(action: ShortcutAction | None = None) None#

Sets the new action for self to be action.

Parameters:

action – The new action. If the action is None, the nothing action will be used.

set_arguments(args: Variant | None = None) None#

Sets the arguments to pass when activating the shortcut.

Parameters:

args – arguments to pass when activating self

set_trigger(trigger: ShortcutTrigger | None = None) None#

Sets the new trigger for self to be trigger.

Parameters:

trigger – The new trigger. If the trigger is None, the never trigger will be used.

Properties#

class Shortcut
props.action: ShortcutAction#

The type of the None singleton.

props.arguments: Variant#

The type of the None singleton.

props.trigger: ShortcutTrigger#

The type of the None singleton.