Skip to content

Gtk.StackSidebar

class — extends Widget, Accessible, Buildable, ConstraintTarget

Uses a sidebar to switch between GtkStack pages.

<picture> <source srcset="sidebar-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkStackSidebar" src="sidebar.png"> </picture>

In order to use a GtkStackSidebar, you simply use a GtkStack to organize your UI flow, and add the sidebar to your sidebar area. You can use StackSidebar.set_stack to connect the GtkStackSidebar to the GtkStack.

CSS nodes

GtkStackSidebar has a single CSS node with name stacksidebar and style class .sidebar.

When circumstances require it, GtkStackSidebar adds the .needs-attention style class to the widgets representing the stack pages.

Constructors

new

@classmethod
def new(cls) -> Widget

Creates a new GtkStackSidebar.

Methods

get_stack

def get_stack(self) -> Stack | None

Retrieves the stack.

set_stack

def set_stack(self, stack: Stack) -> None

Set the GtkStack associated with this GtkStackSidebar.

The sidebar widget will automatically update according to the order and items within the given GtkStack.

Parameters:

  • stack — a GtkStack

Properties

stack

stack: Stack  # read/write

The stack.