Skip to content

Gtk.ActionBar

class — extends Widget, Accessible, Buildable, ConstraintTarget

Presents contextual actions.

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

GtkActionBar is expected to be displayed below the content and expand horizontally to fill the area.

It allows placing children at the start or the end. In addition, it contains an internal centered box which is centered with respect to the full width of the box, even if the children at either side take up different amounts of space.

GtkActionBar as GtkBuildable

The GtkActionBar implementation of the GtkBuildable interface supports adding children at the start or end sides by specifying “start” or “end” as the “type” attribute of a <child> element, or setting the center widget by specifying “center” value.

CSS nodes

actionbar
╰── revealer
    ╰── box
        ├── box.start
        │   ╰── [start children]
        ├── [center widget]
        ╰── box.end
            ╰── [end children]

A GtkActionBar's CSS node is called actionbar. It contains a revealer subnode, which contains a box subnode, which contains two box subnodes at the start and end of the action bar, with start and end style classes respectively, as well as a center node that represents the center child.

Each of the boxes contains children packed for that side.

Constructors

new

@classmethod
def new(cls) -> Widget

Creates a new action bar widget.

Methods

get_center_widget

def get_center_widget(self) -> Widget | None

Retrieves the center bar widget of the bar.

get_revealed

def get_revealed(self) -> bool

Gets whether the contents of the action bar are revealed.

pack_end

def pack_end(self, child: Widget) -> None

Adds a child to the action bar, packed with reference to the end of the action bar.

Parameters:

  • child — the widget to be added

pack_start

def pack_start(self, child: Widget) -> None

Adds a child to the action, packed with reference to the start of the action bar.

Parameters:

  • child — the widget to be added

remove

def remove(self, child: Widget) -> None

Removes a child from the action bar.

Parameters:

  • child — the widget to be removed

set_center_widget

def set_center_widget(self, center_widget: Widget | None = ...) -> None

Sets the center widget for the action bar.

Parameters:

  • center_widget — a widget to use for the center

set_revealed

def set_revealed(self, revealed: bool) -> None

Reveals or conceals the content of the action bar.

Note: this does not show or hide the action bar in the Widget.visible sense, so revealing has no effect if the action bar is hidden.

Parameters:

  • revealed — the new value for the property

Properties

revealed

revealed: bool  # read/write

Controls whether the action bar shows its contents.