Gtk.HeaderBar


Gtk.HeaderBar — A box with a centered child

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.HeaderBar

See also:

Gtk.Box, Gtk.ActionBar


Functions:

Description:

Gtk.HeaderBar is similar to a horizontal Gtk.Box. It allows children to be placed at the start or the end. In addition, it allows a title and subtitle to be displayed. The title will be centered with respect to the width of the box, even if the children at either side take up different amounts of space. The height of the titlebar will be set to provide sufficient space for the subtitle, even if none is currently set. If a subtitle is not needed, the space reservation can be turned off with Gtk.HeaderBar::set_has_subtitle().

Gtk.HeaderBar can add typical window frame controls, such as minimize, maximize and close buttons, or the window icon.


Function Details:

new()

new () -> Gtk.Widget

Creates a new Gtk.HeaderBar widget.

  • Returns: a new Gtk.HeaderBar

  • Since: 3.10


set_title()

set_title (self, title:str=None)

Sets the title of the Gtk.HeaderBar. The title should help a useridentify the current view. A good title should not include theapplication name.

  • Since: 3.10

get_title()

get_title (self) -> str

Retrieves the title of the header. See Gtk.HeaderBar:set_title().

  • Returns: the title of the header, or None if none hasbeen set explicitly. The returned string is owned by the widgetand must not be modified or freed.

  • Since: 3.10


set_subtitle()

set_subtitle (self, subtitle:str=None)

Sets the subtitle of the Gtk.HeaderBar. The title should give a useran additional detail to help him identify the current view. Note that Gtk.HeaderBar by default reserves room for the subtitle,even if none is currently set. If this is not desired, set the“has-subtitle” property to FALSE.

  • Since: 3.10

get_subtitle()

get_subtitle (self) -> str

Retrieves the subtitle of the header. See Gtk.HeaderBar:set_subtitle().

  • Returns: the subtitle of the header, or None if none hasbeen set explicitly. The returned string is owned by the widgetand must not be modified or freed.

  • Since: 3.10


set_has_subtitle()

set_has_subtitle (self, setting:bool)

Sets whether the header bar should reserve spacefor a subtitle, even if none is currently set.

  • Since: 3.12

get_has_subtitle()

get_has_subtitle (self) -> bool

Retrieves whether the header bar reserves space fora subtitle, regardless if one is currently set or not.

  • Returns: True if the header bar reserves spacefor a subtitle

  • Since: 3.12


set_custom_title()

set_custom_title (self, title_widget:Gtk.Widget=None)

Sets a custom title for the Gtk.HeaderBar. The title should help a user identify the current view. Thissupersedes any title set by Gtk.HeaderBar:set_title() orGtk.HeaderBar:set_subtitle(). To achieve the same style asthe builtin title and subtitle, use the “title” and “subtitle”style classes. You should set the custom title to None, for the header titlelabel to be visible again.

  • Since: 3.10

get_custom_title()

get_custom_title (self) -> Gtk.Widget

Retrieves the custom title widget of the header. SeeGtk.HeaderBar:set_custom_title().

  • Returns: the custom title widgetof the header, or None if none has been set explicitly.

  • Since: 3.10


pack_start()

pack_start (self, child:Gtk.Widget)

Adds child to bar, packed with reference to thestart of the bar.

  • Since: 3.10

pack_end()

pack_end (self, child:Gtk.Widget)

Adds child to bar, packed with reference to theend of the bar.

  • Since: 3.10

set_show_close_button()

set_show_close_button (self, setting:bool)

Sets whether this header bar shows the standard window decorations,including close, maximize, and minimize.

  • Since: 3.10

get_show_close_button()

get_show_close_button (self) -> bool

Returns whether this header bar shows the standard windowdecorations.

  • Returns: True if the decorations are shown

  • Since: 3.10


set_decoration_layout()

set_decoration_layout (self, layout:str=None)

Sets the decoration layout for this header bar, overridingthe “gtk-decoration-layout” setting. There can be valid reasons for overriding the setting, suchas a header bar design that does not allow for buttons to takeroom on the right, or only offers room for a single close button.Split header bars are another example for overriding thesetting. The format of the string is button names, separated by commas.A colon separates the buttons that should appear on the leftfrom those on the right. Recognized button names are minimize,maximize, close, icon (the window icon) and menu (a menu buttonfor the fallback app menu). For example, “menu:minimize,maximize,close” specifies a menuon the left, and minimize, maximize and close buttons on the right.

  • Since: 3.12

get_decoration_layout()

get_decoration_layout (self) -> str

Gets the decoration layout set withGtk.HeaderBar:set_decoration_layout().

  • Returns: the decoration layout

  • Since: 3.12


Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class HeaderBar(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("HeaderBar")
        self.set_default_size(-1, 200)
        self.connect("destroy", Gtk.main_quit)

        headerbar = Gtk.HeaderBar()
        headerbar.set_title("HeaderBar Example")
        headerbar.set_subtitle("HeaderBar Subtitle")
        headerbar.set_show_close_button(True)
        self.set_titlebar(headerbar)

        button = Gtk.Button("Open")
        headerbar.pack_start(button)

window = HeaderBar()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""