:right-sidebar: True ViewSwitcher =================================================================== .. currentmodule:: gi.repository.Adw .. class:: ViewSwitcher(**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` An adaptive view switcher. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/view-switcher.png An adaptive view switcher designed to switch between multiple views contained in a :obj:`~gi.repository.Adw.ViewStack` in a similar fashion to :obj:`~gi.repository.Gtk.StackSwitcher`\. ``AdwViewSwitcher`` buttons always have an icon and a label. They can be displayed side by side, or icon on top of the label. This can be controlled via the :obj:`~gi.repository.Adw.ViewSwitcher.props.policy` property. ``AdwViewSwitcher`` is intended to be used in a header bar together with :obj:`~gi.repository.Adw.ViewSwitcherBar` at the bottom of the window, and a :obj:`~gi.repository.Adw.Breakpoint` showing the view switcher bar on narrow sizes, while removing the view switcher from the header bar, as follows: .. code-block:: xml :dedent: max-width: 550sp True stack wide stack It's recommended to set :obj:`~gi.repository.Adw.ViewSwitcher.props.policy` to ``ADW_VIEW_SWITCHER_POLICY_WIDE`` in this case. You may have to adjust the breakpoint condition for your specific pages. CSS nodes -------------------------------------------------------------------------------- ``AdwViewSwitcher`` has a single CSS node with name ``viewswitcher``\. It can have the style classes ``.wide`` and ``.narrow``\, matching its policy. Accessibility -------------------------------------------------------------------------------- ``AdwViewSwitcher`` uses the ``GTK_ACCESSIBLE_ROLE_TAB_LIST`` role and uses the ``GTK_ACCESSIBLE_ROLE_TAB`` for its buttons. Constructors ------------ .. rst-class:: interim-class .. class:: ViewSwitcher :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``AdwViewSwitcher``\. Methods ------- .. rst-class:: interim-class .. class:: ViewSwitcher :no-index: .. method:: get_policy() -> ~gi.repository.Adw.ViewSwitcherPolicy Gets the policy of ``self``\. .. method:: get_stack() -> ~gi.repository.Adw.ViewStack | None Gets the stack controlled by ``self``\. .. method:: set_policy(policy: ~gi.repository.Adw.ViewSwitcherPolicy) -> None Sets the policy of ``self``\. :param policy: the new policy .. method:: set_stack(stack: ~gi.repository.Adw.ViewStack | None = None) -> None Sets the stack controlled by ``self``\. :param stack: a stack Properties ---------- .. rst-class:: interim-class .. class:: ViewSwitcher :no-index: .. attribute:: props.policy :type: ~gi.repository.Adw.ViewSwitcherPolicy The type of the None singleton. .. attribute:: props.stack :type: ~gi.repository.Adw.ViewStack The type of the None singleton.