: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` :Constructors: :: ViewStack(**properties) new() -> Gtk.Widget 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 Whether the stack is horizontally homogeneous. 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. .. attribute:: props.pages :type: ~gi.repository.Gtk.SelectionModel A selection model with the stack's pages. 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. .. attribute:: props.vhomogeneous :type: bool Whether the stack is vertically homogeneous. 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. .. attribute:: props.visible_child :type: ~gi.repository.Gtk.Widget The widget currently visible in the stack. .. attribute:: props.visible_child_name :type: str The name of the widget currently visible in the stack. See :obj:`~gi.repository.Adw.ViewStack.props.visible_child`.