: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 `_. 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 name of the section to show. This should be the section-name of one of the ``GtkShortcutsSection`` objects that are in this shortcuts window. .. attribute:: props.view_name :type: str The view name by which to filter the contents. This should correspond to the :obj:`~gi.repository.Gtk.ShortcutsGroup.props.view` property of some of the :obj:`~gi.repository.Gtk.ShortcutsGroup` objects that are inside this shortcuts window. Set this to :const:`None` to show all groups. 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 Escape key. .. method:: search() -> None Emitted when the user uses a keybinding to start a search. This is a `keybinding signal `_. The default binding for this signal is Control-F.