:right-sidebar: True ViewStack =================================================================== .. currentmodule:: gi.repository.Adw .. class:: ViewStack(**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 view container for :obj:`~gi.repository.Adw.ViewSwitcher`\. ``AdwViewStack`` is a container which only shows one page at a time. It is typically used to hold an application's main views. It doesn't provide a way to transition between pages. Instead, a separate widget such as :obj:`~gi.repository.Adw.ViewSwitcher` can be used with ``AdwViewStack`` to provide this functionality. ``AdwViewStack`` pages can have a title, an icon, an attention request, and a numbered badge that :obj:`~gi.repository.Adw.ViewSwitcher` will use to let users identify which page is which. Set them using the :obj:`~gi.repository.Adw.ViewStackPage.props.title`\, :obj:`~gi.repository.Adw.ViewStackPage.props.icon_name`\, :obj:`~gi.repository.Adw.ViewStackPage.props.needs_attention`\, and :obj:`~gi.repository.Adw.ViewStackPage.props.badge_number` properties. Unlike :obj:`~gi.repository.Gtk.Stack`\, transitions between views are not animated. ``AdwViewStack`` maintains a :obj:`~gi.repository.Adw.ViewStackPage` object for each added child, which holds additional per-child properties. You obtain the :obj:`~gi.repository.Adw.ViewStackPage` for a child with :obj:`~gi.repository.ViewStack.get_page` and you can obtain a :obj:`~gi.repository.Gtk.SelectionModel` containing all the pages with :obj:`~gi.repository.ViewStack.get_pages`\. AdwViewStack as GtkBuildable -------------------------------------------------------------------------------- To set child-specific properties in a .ui file, create :obj:`~gi.repository.Adw.ViewStackPage` objects explicitly, and set the child widget as a property on it: .. code-block:: xml :dedent: overview Overview Welcome! CSS nodes -------------------------------------------------------------------------------- ``AdwViewStack`` has a single CSS node named ``stack``\. Accessibility -------------------------------------------------------------------------------- ``AdwViewStack`` uses the ``GTK_ACCESSIBLE_ROLE_TAB_PANEL`` for the stack pages which are the accessible parent objects of the child widgets. Constructors ------------ .. rst-class:: interim-class .. class:: ViewStack :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``AdwViewStack``\. Methods ------- .. rst-class:: interim-class .. class:: ViewStack :no-index: .. method:: add(child: ~gi.repository.Gtk.Widget) -> ~gi.repository.Adw.ViewStackPage Adds a child to ``self``\. :param child: the widget to add .. method:: add_named(child: ~gi.repository.Gtk.Widget, name: str | None = None) -> ~gi.repository.Adw.ViewStackPage Adds a child to ``self``\. The child is identified by the ``name``\. :param child: the widget to add :param name: the name for ``child`` .. method:: add_titled(child: ~gi.repository.Gtk.Widget, name: str | None, title: str) -> ~gi.repository.Adw.ViewStackPage Adds a child to ``self``\. The child is identified by the ``name``\. The ``title`` will be used by :obj:`~gi.repository.Adw.ViewSwitcher` to represent ``child``\, so it should be short. :param child: the widget to add :param name: the name for ``child`` :param title: a human-readable title for ``child`` .. method:: add_titled_with_icon(child: ~gi.repository.Gtk.Widget, name: str | None, title: str, icon_name: str) -> ~gi.repository.Adw.ViewStackPage Adds a child to ``self``\. The child is identified by the ``name``\. The ``title`` and ``icon_name`` will be used by :obj:`~gi.repository.Adw.ViewSwitcher` to represent ``child``\. .. versionadded:: 1.2 :param child: the widget to add :param name: the name for ``child`` :param title: a human-readable title for ``child`` :param icon_name: an icon name for ``child`` .. method:: get_child_by_name(name: str) -> ~gi.repository.Gtk.Widget | None Finds the child with ``name`` in ``self``\. :param name: the name of the child to find .. method:: get_hhomogeneous() -> bool Gets whether ``self`` is horizontally homogeneous. .. method:: get_page(child: ~gi.repository.Gtk.Widget) -> ~gi.repository.Adw.ViewStackPage Gets the :obj:`~gi.repository.Adw.ViewStackPage` object for ``child``\. :param child: a child of ``self`` .. method:: get_pages() -> ~gi.repository.Gtk.SelectionModel Returns a :obj:`~gi.repository.Gio.ListModel` that contains the pages of the stack. This can be used to keep an up-to-date view. The model also implements :obj:`~gi.repository.Gtk.SelectionModel` and can be used to track and change the visible page. .. method:: get_vhomogeneous() -> bool Gets whether ``self`` is vertically homogeneous. .. method:: get_visible_child() -> ~gi.repository.Gtk.Widget | None Gets the currently visible child of ``self``\. .. method:: get_visible_child_name() -> str | None Returns the name of the currently visible child of ``self``\. .. method:: remove(child: ~gi.repository.Gtk.Widget) -> None Removes a child widget from ``self``\. :param child: the child to remove .. method:: set_hhomogeneous(hhomogeneous: bool) -> None Sets ``self`` to be horizontally homogeneous or not. If the stack is horizontally homogeneous, it allocates the same width for all children. If it's ``FALSE``\, the stack may change width when a different child becomes visible. :param hhomogeneous: whether to make ``self`` horizontally homogeneous .. method:: set_vhomogeneous(vhomogeneous: bool) -> None Sets ``self`` to be vertically homogeneous or not. If the stack is vertically homogeneous, it allocates the same height for all children. If it's ``FALSE``\, the stack may change height when a different child becomes visible. :param vhomogeneous: whether to make ``self`` vertically homogeneous .. method:: set_visible_child(child: ~gi.repository.Gtk.Widget) -> None Makes ``child`` the visible child of ``self``\. :param child: a child of ``self`` .. method:: set_visible_child_name(name: str) -> None Makes the child with ``name`` visible. See :obj:`~gi.repository.Adw.ViewStack.props.visible_child`\. :param name: the name of the child Properties ---------- .. rst-class:: interim-class .. class:: ViewStack :no-index: .. attribute:: props.hhomogeneous :type: bool The type of the None singleton. .. attribute:: props.pages :type: ~gi.repository.Gtk.SelectionModel The type of the None singleton. .. attribute:: props.vhomogeneous :type: bool The type of the None singleton. .. attribute:: props.visible_child :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. attribute:: props.visible_child_name :type: str The type of the None singleton.