ShortcutLabel#

Added in version 1.8.

class ShortcutLabel(**properties: Any)#

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

A widget that displays a keyboard shortcut.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label.png

The shown shortcut can be set using the accelerator property.

Optionally, if no shortcut is set, AdwShortcutLabel will display a placeholder set with the disabled_text property.

The following types of shortcuts can be displayed:

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-single.png
  • Multiple alternative shortcuts, separated with spaces, e.g. <Shift>A Home:

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-alternative.png
  • A range of shortcuts, separated with ..., e.g. <Alt>1...9:

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-range.png
  • Multiple keys pressed at once, separated with &, e.g. Control_L&Control_R:

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-multiple.png
  • Multiple shortcuts or keys, pressed sequentially, separated with +, e.g. <Control>C+<Control>X:

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-sequence.png
::: note

<, > and & need to be escaped as &lt;, &gt; and &amp; when used in UI files.

CSS nodes#

AdwShortcutLabel has a single CSS node with name shortcut-label. The individual keycap labels each have the .keycap style class, while the labels separating them have the .dimmed style class.

Accessibility#

AdwShortcutLabel uses the label role.

See also: ShortcutsDialog.

Constructors#

class ShortcutLabel
classmethod new(accelerator: str) Widget#

Creates a new AdwShortcutLabel showing accelerator.

Added in version 1.8.

Parameters:

accelerator – the accelerator to show

Methods#

class ShortcutLabel
get_accelerator() str#

Gets the accelerator displayed by self.

Added in version 1.8.

get_disabled_text() str#

Gets the text displayed by self when no accelerator is set.

Added in version 1.8.

set_accelerator(accelerator: str) None#

Sets the accelerator to be displayed by self.

Added in version 1.8.

Parameters:

accelerator – the accelerator to be displayed

set_disabled_text(disabled_text: str) None#

Sets the text to be displayed by self when no accelerator is set.

Added in version 1.8.

Parameters:

disabled_text – the text displayed when no accelerator is set

Properties#

class ShortcutLabel
props.accelerator: str#

The type of the None singleton.

Added in version 1.8.

props.disabled_text: str#

The type of the None singleton.

Added in version 1.8.