Adw.ViewStack¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.ViewStack(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A view container for [class`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 [class`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 [class`ViewSwitcher`] will use to let users identify which page is which. Set them using the [property`ViewStackPage`:py:data::title<Adw.ViewStack.props.title>], [property`ViewStackPage`:py:data::icon-name<Adw.ViewStack.props.icon_name>], [property`ViewStackPage`:py:data::needs-attention<Adw.ViewStack.props.needs_attention>], and [property`ViewStackPage`:py:data::badge-number<Adw.ViewStack.props.badge_number>] properties.Unlike [class`Gtk`.Stack], transitions between views are not animated.
AdwViewStack
maintains a [class`ViewStackPage`] object for each added child, which holds additional per-child properties. You obtain the [class`ViewStackPage`] for a child with [method`ViewStack`.get_page] and you can obtain a [iface`Gtk`.SelectionModel] containing all the pages with [method`ViewStack`.get_pages].To set child-specific properties in a .ui file, create [class`ViewStackPage`] objects explicitly, and set the child widget as a property on it:
```xml
<child>
overview Overview
Welcome! </object>
/object /child /object ```
- CSS nodes
AdwViewStack
has a single CSS node namedstack
.- Accessibility
AdwViewStack
uses theGTK_ACCESSIBLE_ROLE_TAB_PANEL
for the stack pages which are the accessible parent objects of the child widgets.- classmethod new()¶
- Returns:
the newly created
AdwViewStack
- Return type:
Creates a new
AdwViewStack
.
- add(child)¶
- Parameters:
child (
Gtk.Widget
) – the widget to add- Returns:
the [class`ViewStackPage`] for child
- Return type:
Adds a child to self.
- add_named(child, name)¶
- Parameters:
child (
Gtk.Widget
) – the widget to add
- Returns:
the
AdwViewStackPage
for child- Return type:
Adds a child to self.
The child is identified by the name.
- add_titled(child, name, title)¶
- Parameters:
child (
Gtk.Widget
) – the widget to addtitle (
str
) – a human-readable title for child
- Returns:
the
AdwViewStackPage
for child- Return type:
Adds a child to self.
The child is identified by the name. The title will be used by [class`ViewSwitcher`] to represent child, so it should be short.
- add_titled_with_icon(child, name, title, icon_name)¶
- Parameters:
child (
Gtk.Widget
) – the widget to addtitle (
str
) – a human-readable title for childicon_name (
str
) – an icon name for child
- Returns:
the
AdwViewStackPage
for child- Return type:
Adds a child to self.
The child is identified by the name. The title and icon_name will be used by [class`ViewSwitcher`] to represent child.
New in version 1.2.
- get_child_by_name(name)¶
- Parameters:
name (
str
) – the name of the child to find- Returns:
the requested child
- Return type:
Gtk.Widget
orNone
Finds the child with name in self.
- get_hhomogeneous()¶
- Returns:
whether self is horizontally homogeneous
- Return type:
Gets whether self is horizontally homogeneous.
- get_page(child)¶
- Parameters:
child (
Gtk.Widget
) – a child of self- Returns:
the page object for child
- Return type:
Gets the [class`ViewStackPage`] object for child.
- get_pages()¶
- Returns:
a
GtkSelectionModel
for the stack’s children- Return type:
Returns a [iface`Gio`.ListModel] that contains the pages of the stack.
This can be used to keep an up-to-date view. The model also implements [iface`Gtk`.SelectionModel] and can be used to track and change the visible page.
- get_vhomogeneous()¶
- Returns:
whether self is vertically homogeneous
- Return type:
Gets whether self is vertically homogeneous.
- get_visible_child()¶
- Returns:
the visible child
- Return type:
Gtk.Widget
orNone
Gets the currently visible child of self.
- get_visible_child_name()¶
-
Returns the name of the currently visible child of self.
- remove(child)¶
- Parameters:
child (
Gtk.Widget
) – the child to remove
Removes a child widget from self.
- set_hhomogeneous(hhomogeneous)¶
- Parameters:
hhomogeneous (
bool
) – whether to make self horizontally homogeneous
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.
- set_vhomogeneous(vhomogeneous)¶
- Parameters:
vhomogeneous (
bool
) – whether to make self vertically homogeneous
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.
- set_visible_child(child)¶
- Parameters:
child (
Gtk.Widget
) – a child of self
Makes child the visible child of self.
Property Details¶
- Adw.ViewStack.props.hhomogeneous¶
- Name:
hhomogeneous
- Type:
- Default Value:
- Flags:
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.
- Adw.ViewStack.props.pages¶
- Name:
pages
- Type:
- Default Value:
- Flags:
A selection model with the stack’s pages.
This can be used to keep an up-to-date view. The model also implements [iface`Gtk`.SelectionModel] and can be used to track and change the visible page.
- Adw.ViewStack.props.vhomogeneous¶
- Name:
vhomogeneous
- Type:
- Default Value:
- Flags:
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.
- Adw.ViewStack.props.visible_child¶
- Name:
visible-child
- Type:
- Default Value:
- Flags:
The widget currently visible in the stack.