Skip to content

Gtk.StackSwitcher

class — extends Widget, Accessible, Buildable, ConstraintTarget, Orientable

Shows a row of buttons to switch between GtkStack pages.

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

It acts as a controller for the associated GtkStack.

All the content for the buttons comes from the properties of the stacks StackPage objects; the button visibility in a GtkStackSwitcher widget is controlled by the visibility of the child in the GtkStack.

It is possible to associate multiple GtkStackSwitcher widgets with the same GtkStack widget.

CSS nodes

GtkStackSwitcher has a single CSS node named stackswitcher and style class .stack-switcher.

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

Accessibility

GtkStackSwitcher uses the AccessibleRole.tab_list role and uses the AccessibleRole.tab role for its buttons.

Orientable

Since GTK 4.4, GtkStackSwitcher implements GtkOrientable allowing the stack switcher to be made vertical with gtk_orientable_set_orientation().

Constructors

new

@classmethod
def new(cls) -> Widget

Create a new GtkStackSwitcher.

Methods

get_stack

def get_stack(self) -> Stack | None

Retrieves the stack.

set_stack

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

Sets the stack to control.

Parameters:

  • stack — a GtkStack

Properties

stack

stack: Stack  # read/write

The stack.