Adw.Banner

g Adw.Banner Adw.Banner GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Actionable->Adw.Banner Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Adw.Banner

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Actionable (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (title)

get_button_label ()

get_revealed ()

get_title ()

get_use_markup ()

set_button_label (label)

set_revealed (revealed)

set_title (title)

set_use_markup (use_markup)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.Actionable (4)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Actionable (2)

Name

Type

Flags

Short Description

button-label

str

r/w/en

revealed

bool

r/w/en

title

str

r/w/en

use-markup

bool

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

button-clicked

This signal is emitted after the action button has been clicked.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Adw.Banner(**kwargs)
Bases:

Gtk.Widget, Gtk.Actionable

Abstract:

No

Structure:

Adw.BannerClass

A bar with contextual information.

<picture> <source srcset=”banner-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”banner.png” alt=”banner”> </picture>

Banners are hidden by default, use [property`Banner`:py:data::revealed<Adw.Banner.props.revealed>] to show them.

Banners have a title, set with [property`Banner`:py:data::title<Adw.Banner.props.title>]. Titles can be marked up with Pango markup, use [property`Banner`:py:data::use-markup<Adw.Banner.props.use_markup>] to enable it.

The title will be shown centered or left-aligned depending on available space.

Banners can optionally have a button with text on it, set through [property`Banner`:py:data::button-label<Adw.Banner.props.button_label>]. The button can be used with a GAction, or with the [signal`Banner`:py:func:::button-clicked<Adw.Banner.signals.button_clicked>] signal.

CSS nodes

AdwBanner has a main CSS node with the name banner.

New in version 1.3.

classmethod new(title)
Parameters:

title (str) – the banner title

Returns:

the newly created AdwBanner

Return type:

Gtk.Widget

Creates a new AdwBanner.

New in version 1.3.

get_button_label()
Returns:

the button label for self

Return type:

str or None

Gets the button label for self.

New in version 1.3.

get_revealed()
Returns:

Whether a banner is revealed

Return type:

bool

Gets if a banner is revealed

New in version 1.3.

get_title()
Returns:

the title for self

Return type:

str

Gets the title for self.

New in version 1.3.

get_use_markup()
Returns:

whether to use markup

Return type:

bool

Gets whether to use Pango markup for the banner title.

New in version 1.3.

set_button_label(label)
Parameters:

label (str or None) – the label

Sets the button label for self.

If set to "" or NULL, the button won’t be shown.

The button can be used with a GAction, or with the [signal`Banner`:py:func:::button-clicked<Adw.Banner.signals.button_clicked>] signal.

New in version 1.3.

set_revealed(revealed)
Parameters:

revealed (bool) – whether a banner should be revealed

Sets whether a banner should be revealed

New in version 1.3.

set_title(title)
Parameters:

title (str) – the title

Sets the title for this banner.

See also: [property`Banner`:py:data::use-markup<Adw.Banner.props.use_markup>].

New in version 1.3.

set_use_markup(use_markup)
Parameters:

use_markup (bool) – whether to use markup

Sets whether to use Pango markup for the banner title.

See also [func`Pango`.parse_markup].

New in version 1.3.

Signal Details

Adw.Banner.signals.button_clicked(banner)
Signal Name:

button-clicked

Flags:

RUN_LAST

Parameters:

banner (Adw.Banner) – The object which received the signal

This signal is emitted after the action button has been clicked.

It can be used as an alternative to setting an action.

New in version 1.3.

Property Details

Adw.Banner.props.button_label
Name:

button-label

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The label to show on the button.

If set to "" or NULL, the button won’t be shown.

The button can be used with a GAction, or with the [signal`Banner`:py:func:::button-clicked<Adw.Banner.signals.button_clicked>] signal.

New in version 1.3.

Adw.Banner.props.revealed
Name:

revealed

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the banner is currently revealed.

New in version 1.3.

Adw.Banner.props.title
Name:

title

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The title for this banner.

See also: [property`Banner`:py:data::use-markup<Adw.Banner.props.use_markup>].

New in version 1.3.

Adw.Banner.props.use_markup
Name:

use-markup

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to use Pango markup for the banner title.

See also [func`Pango`.parse_markup].

New in version 1.3.