:right-sidebar: True ShortcutsWindow =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: ShortcutsWindow(*args, **kwargs) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Window`, :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`, :class:`~gi.repository.Gtk.Native`, :class:`~gi.repository.Gtk.Root`, :class:`~gi.repository.Gtk.ShortcutManager` A ``GtkShortcutsWindow`` shows information about the keyboard shortcuts and gestures of an application. The shortcuts can be grouped, and you can have multiple sections in this window, corresponding to the major modes of your application. Additionally, the shortcuts can be filtered by the current view, to avoid showing information that is not relevant in the current application context. The recommended way to construct a ``GtkShortcutsWindow`` is with :obj:`~gi.repository.Gtk.Builder`\, by using the ```` tag to populate a ``GtkShortcutsWindow`` with one or more :obj:`~gi.repository.Gtk.ShortcutsSection` objects, which contain one or more :obj:`~gi.repository.Gtk.ShortcutsGroup` instances, which, in turn, contain :obj:`~gi.repository.Gtk.ShortcutsShortcut` instances. If you need to add a section programmatically, use :obj:`~gi.repository.Gtk.ShortcutsWindow.add_section` instead of :obj:`~gi.repository.Gtk.Window.set_child`\, as the shortcuts window manages its children directly. A simple example: -------------------------------------------------------------------------------- .. image:: https://docs.gtk.org/gtk4/gedit-shortcuts.png This example has as single section. As you can see, the shortcut groups are arranged in columns, and spread across several pages if there are too many to find on a single page. The .ui file for this example can be found `here `__\. An example with multiple views: -------------------------------------------------------------------------------- .. image:: https://docs.gtk.org/gtk4/clocks-shortcuts.png This example shows a ``GtkShortcutsWindow`` that has been configured to show only the shortcuts relevant to the "stopwatch" view. The .ui file for this example can be found `here `__\. An example with multiple sections: -------------------------------------------------------------------------------- .. image:: https://docs.gtk.org/gtk4/builder-shortcuts.png This example shows a ``GtkShortcutsWindow`` with two sections, "Editor Shortcuts" and "Terminal Shortcuts". The .ui file for this example can be found `here `__\. Shortcuts and Gestures -------------------------------------------------------------------------------- The following signals have default keybindings: - :obj:`~gi.repository.Gtk.ShortcutsWindow.signals.close` - :obj:`~gi.repository.Gtk.ShortcutsWindow.signals.search` CSS nodes -------------------------------------------------------------------------------- ``GtkShortcutsWindow`` has a single CSS node with the name ``window`` and style class ``.shortcuts``\. Methods ------- .. rst-class:: interim-class .. class:: ShortcutsWindow :no-index: .. method:: add_section(section: ~gi.repository.Gtk.ShortcutsSection) -> None Adds a section to the shortcuts window. This is the programmatic equivalent to using :obj:`~gi.repository.Gtk.Builder` and a ```` tag to add the child. Using :obj:`~gi.repository.Gtk.Window.set_child` is not appropriate as the shortcuts window manages its children internally. .. versionadded:: 4.14 :param section: the ``GtkShortcutsSection`` to add Properties ---------- .. rst-class:: interim-class .. class:: ShortcutsWindow :no-index: .. attribute:: props.section_name :type: str The type of the None singleton. .. attribute:: props.view_name :type: str The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: ShortcutsWindow.signals :no-index: .. method:: close() -> None Emitted when the user uses a keybinding to close the window. This is a `keybinding signal `__\. The default binding for this signal is the :kbd:`Escape` key. .. method:: search() -> None The type of the None singleton.