ActionBar

The ActionBar widget provides a full width bar for widgets such as Button and Label widgets. It is usually placed below the application content and is commonly used in place of a Statusbar.

Constructor

The ActionBar is constructed using:

actionbar = Gtk.ActionBar()

Methods

Items can be packed into the container at the start (left) or end (right):

actionbar.pack_start(child)
actionbar.pack_end(child)

If required, items can also be placed in the center:

actionbar.set_center_widget(child)

The center widget can also be retrieved via:

actionbar.get_center_widget()

Properties

The property items available for use with the ActionBar are:

  • "pack-type" - can be set to either Gtk.PackType.START or Gtk.Pack_type.END for left or right placement of child widgets.
  • "position" - specifies the index of the child in the ActionBar.

Example

Below is an example of an ActionBar:

#!/usr/bin/env python3

from gi.repository import Gtk

class ActionBar(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_default_size(200, 200)
        self.connect("destroy", Gtk.main_quit)

        grid = Gtk.Grid()
        self.add(grid)

        label = Gtk.Label()
        label.set_vexpand(True)
        grid.attach(label, 0, 0, 1, 1)

        actionbar = Gtk.ActionBar()
        actionbar.set_hexpand(True)
        grid.attach(actionbar, 0, 1, 1, 1)

        button = Gtk.Button("Cut")
        actionbar.pack_start(button)
        button = Gtk.Button("Copy")
        actionbar.pack_start(button)
        button = Gtk.Button("Paste")
        actionbar.pack_end(button)

    def run(self):
        self.show_all()

window = ActionBar()
window.run()

Gtk.main()

Download: ActionBar