:right-sidebar: True ShortcutLabel =================================================================== .. currentmodule:: gi.repository.Adw .. versionadded:: 1.8 .. class:: ShortcutLabel(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` A widget that displays a keyboard shortcut. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label.png The shown shortcut can be set using the :obj:`~gi.repository.Adw.ShortcutLabel.props.accelerator` property. Optionally, if no shortcut is set, ``AdwShortcutLabel`` will display a placeholder set with the :obj:`~gi.repository.Adw.ShortcutLabel.props.disabled_text` property. The following types of shortcuts can be displayed: - A single shortcut in :obj:`~gi.repository.Gtk.accelerator_parse` format, e.g. ``C``\: .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-single.png - Multiple alternative shortcuts, separated with spaces, e.g. ``A Home``\: .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-alternative.png - A range of shortcuts, separated with ``...``\, e.g. ``1...9``\: .. image:: 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``\: .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-multiple.png - Multiple shortcuts or keys, pressed sequentially, separated with ``+``\, e.g. ``C+X``\: .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/shortcut-label-sequence.png ::: note ``<``\, ``>`` and ``&`` need to be escaped as ``<``\, ``>`` and ``&`` 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 :obj:`~gi.repository.Gtk.AccessibleRole.label` role. See also: :obj:`~gi.repository.Adw.ShortcutsDialog`\. Constructors ------------ .. rst-class:: interim-class .. class:: ShortcutLabel :no-index: .. classmethod:: new(accelerator: str) -> ~gi.repository.Gtk.Widget Creates a new ``AdwShortcutLabel`` showing ``accelerator``\. .. versionadded:: 1.8 :param accelerator: the accelerator to show Methods ------- .. rst-class:: interim-class .. class:: ShortcutLabel :no-index: .. method:: get_accelerator() -> str Gets the accelerator displayed by ``self``\. .. versionadded:: 1.8 .. method:: get_disabled_text() -> str Gets the text displayed by ``self`` when no accelerator is set. .. versionadded:: 1.8 .. method:: set_accelerator(accelerator: str) -> None Sets the accelerator to be displayed by ``self``\. .. versionadded:: 1.8 :param accelerator: the accelerator to be displayed .. method:: set_disabled_text(disabled_text: str) -> None Sets the text to be displayed by ``self`` when no accelerator is set. .. versionadded:: 1.8 :param disabled_text: the text displayed when no accelerator is set Properties ---------- .. rst-class:: interim-class .. class:: ShortcutLabel :no-index: .. attribute:: props.accelerator :type: str The type of the None singleton. .. versionadded:: 1.8 .. attribute:: props.disabled_text :type: str The type of the None singleton. .. versionadded:: 1.8