ShortcutAction#
Superclasses: Object
Subclasses: ActivateAction, CallbackAction, MnemonicAction, NamedAction, NothingAction, SignalAction
GtkShortcutAction encodes an action that can be triggered by a
keyboard shortcut.
GtkShortcutActions contain functions that allow easy presentation
to end users as well as being printed for debugging.
All GtkShortcutActions are immutable, you can only specify their
properties during construction. If you want to change a action, you
have to replace it with a new one. If you need to pass arguments to
an action, these are specified by the higher-level GtkShortcut object.
To activate a GtkShortcutAction manually, activate
can be called.
GTK provides various actions:
MnemonicAction: a shortcut action that calls
CallbackAction: a shortcut action that invokesa given callback
SignalAction: a shortcut action that emits agiven signal
ActivateAction: a shortcut action that calls
NamedAction: a shortcut action that calls
NothingAction: a shortcut action that does nothing
Constructors#
- class ShortcutAction
- classmethod parse_string(string: str) ShortcutAction | None#
Tries to parse the given string into an action.
On success, the parsed action is returned. When parsing failed,
Noneis returned.The accepted strings are:
nothing, forGtkNothingActionactivate, forGtkActivateActionmnemonic-activate, forGtkMnemonicActionaction(NAME), for aGtkNamedActionfor the action namedNAMEsignal(NAME), for aGtkSignalActionfor the signalNAME
- Parameters:
string – the string to parse
Methods#
- class ShortcutAction
- activate(flags: ShortcutActionFlags, widget: Widget, args: Variant | None = None) bool#
Activates the action on the
widgetwith the givenargs.Note that some actions ignore the passed in
flags,widgetorargs.Activation of an action can fail for various reasons. If the action is not supported by the
widget, if theargsdon’t match the action or if the activation otherwise had no effect,Falsewill be returned.- Parameters:
flags – flags to activate with
widget – Target of the activation
args – arguments to pass