Gtk.InfoBar

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible 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.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.InfoBar Gtk.InfoBar Gtk.Widget->Gtk.InfoBar

Example

../_images/InfoBar.png
Subclasses:

None

Methods

Inherited:

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

Structs:

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

class

new ()

add_action_widget (child, response_id)

add_button (button_text, response_id)

add_child (widget)

get_message_type ()

get_revealed ()

get_show_close_button ()

remove_action_widget (widget)

remove_child (widget)

response (response_id)

set_default_response (response_id)

set_message_type (message_type)

set_response_sensitive (response_id, setting)

set_revealed (revealed)

set_show_close_button (setting)

Virtual Methods

Inherited:

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

Properties

Inherited:

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

Name

Type

Flags

Short Description

message-type

Gtk.MessageType

r/w/c/en

revealed

bool

r/w/en

show-close-button

bool

r/w/c/en

Signals

Inherited:

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

Name

Short Description

close

Gets emitted when the user uses a keybinding to dismiss the info bar.

response

Emitted when an action widget is clicked.

Fields

Inherited:

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

Class Details

class Gtk.InfoBar(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

GtkInfoBar can be used to show messages to the user without a dialog.

An example Gtk.InfoBar

It is often temporarily shown at the top or bottom of a document. In contrast to [class`Gtk`.Dialog], which has an action area at the bottom, GtkInfoBar has an action area at the side.

The API of GtkInfoBar is very similar to GtkDialog, allowing you to add buttons to the action area with [method`Gtk`.InfoBar.add_button] or [ctor`Gtk`.InfoBar.new_with_buttons]. The sensitivity of action widgets can be controlled with [method`Gtk`.InfoBar.set_response_sensitive].

To add widgets to the main content area of a GtkInfoBar, use [method`Gtk`.InfoBar.add_child].

Similar to [class`Gtk`.MessageDialog], the contents of a GtkInfoBar can by classified as error message, warning, informational message, etc, by using [method`Gtk`.InfoBar.set_message_type]. GTK may use the message type to determine how the message is displayed.

A simple example for using a GtkInfoBar : ```c Gtk.Widget *message_label; Gtk.Widget *widget; Gtk.Widget *grid; Gtk.InfoBar *bar;

// set up info bar widget = Gtk.InfoBar.new (); bar = GTK_INFO_BAR (widget); grid = Gtk.Grid.new ();

message_label = Gtk.Label.new (“”); Gtk.InfoBar.add_child (bar, message_label); Gtk.InfoBar.add_button (bar, _(”_OK”), Gtk.ResponseType.OK); g_signal_connect (bar, “response”, G_CALLBACK (Gtk.Widget.hide), None); Gtk.Grid.attach (GTK_GRID (grid), widget, 0, 2, 1, 1);

// …

// show an error message Gtk.Label.set_text (GTK_LABEL (message_label), “An error occurred!”); Gtk.InfoBar.set_message_type (bar, Gtk.MessageType.ERROR); Gtk.Widget.show (bar); ```

Gtk.InfoBar as Gtk.Buildable

GtkInfoBar supports a custom <action-widgets> element, which can contain multiple <action-widget> elements. The “response” attribute specifies a numeric response, and the content of the element is the id of widget (which should be a child of the dialogs action_area).

GtkInfoBar supports adding action widgets by specifying “action” as the “type” attribute of a <child> element. The widget will be added either to the action area. The response id has to be associated with the action widget using the <action-widgets> element.

CSS nodes

GtkInfoBar has a single CSS node with name infobar. The node may get one of the style classes .info, .warning, .error or .question, depending on the message type. If the info bar shows a close button, that button will have the .close style class applied.

Deprecated since version 4.10: There is no replacement in GTK for an “info bar” widget; you can use [class`Gtk`.Revealer] with a [class`Gtk`.Box] containing a [class`Gtk`.Label] and an optional [class`Gtk`.Button], according to your application’s design.

classmethod new()[source]
Returns:

a new GtkInfoBar object

Return type:

Gtk.Widget

Creates a new GtkInfoBar object.

Deprecated since version 4.10.

add_action_widget(child, response_id)[source]
Parameters:
  • child (Gtk.Widget) – an activatable widget

  • response_id (int) – response ID for child

Add an activatable widget to the action area of a GtkInfoBar.

This also connects a signal handler that will emit the [signal`Gtk`.InfoBar::response] signal on the message area when the widget is activated. The widget is appended to the end of the message areas action area.

Deprecated since version 4.10.

add_button(button_text, response_id)[source]
Parameters:
  • button_text (str) – text of button

  • response_id (int) – response ID for the button

Returns:

the GtkButton widget that was added

Return type:

Gtk.Button

Adds a button with the given text.

Clicking the button will emit the [signal`Gtk`.InfoBar::response] signal with the given response_id. The button is appended to the end of the info bar’s action area. The button widget is returned, but usually you don’t need it.

Deprecated since version 4.10.

add_child(widget)[source]
Parameters:

widget (Gtk.Widget) – the child to be added

Adds a widget to the content area of the info bar.

Deprecated since version 4.10.

get_message_type()[source]
Returns:

the message type of the message area.

Return type:

Gtk.MessageType

Returns the message type of the message area.

Deprecated since version 4.10.

get_revealed()[source]
Returns:

the current value of the [property`Gtk`.InfoBar:revealed] property

Return type:

bool

Returns whether the info bar is currently revealed.

Deprecated since version 4.10.

get_show_close_button()[source]
Returns:

True if the widget displays standard close button

Return type:

bool

Returns whether the widget will display a standard close button.

Deprecated since version 4.10.

remove_action_widget(widget)[source]
Parameters:

widget (Gtk.Widget) – an action widget to remove

Removes a widget from the action area of self.

The widget must have been put there by a call to [method`Gtk`.InfoBar.add_action_widget] or [method`Gtk`.InfoBar.add_button].

Deprecated since version 4.10.

remove_child(widget)[source]
Parameters:

widget (Gtk.Widget) – a child that has been added to the content area

Removes a widget from the content area of the info bar.

Deprecated since version 4.10.

response(response_id)[source]
Parameters:

response_id (int) – a response ID

Emits the “response” signal with the given response_id.

Deprecated since version 4.10.

set_default_response(response_id)[source]
Parameters:

response_id (int) – a response ID

Sets the last widget in the info bar’s action area with the given response_id as the default widget for the dialog.

Pressing “Enter” normally activates the default widget.

Note that this function currently requires self to be added to a widget hierarchy.

Deprecated since version 4.10.

set_message_type(message_type)[source]
Parameters:

message_type (Gtk.MessageType) – a GtkMessageType

Sets the message type of the message area.

GTK uses this type to determine how the message is displayed.

Deprecated since version 4.10.

set_response_sensitive(response_id, setting)[source]
Parameters:
  • response_id (int) – a response ID

  • setting (bool) – True for sensitive

Sets the sensitivity of action widgets for response_id.

Calls gtk_widget_set_sensitive (widget, setting) for each widget in the info bars’s action area with the given response_id. A convenient way to sensitize/desensitize buttons.

Deprecated since version 4.10.

set_revealed(revealed)[source]
Parameters:

revealed (bool) – The new value of the property

Sets whether the GtkInfoBar is revealed.

Changing this will make self reveal or conceal itself via a sliding transition.

Note: this does not show or hide self in the [property`Gtk`.Widget:visible] sense, so revealing has no effect if [property`Gtk`.Widget:visible] is False.

Deprecated since version 4.10.

set_show_close_button(setting)[source]
Parameters:

setting (bool) – True to include a close button

If true, a standard close button is shown.

When clicked it emits the response Gtk.ResponseType.CLOSE.

Deprecated since version 4.10.

Signal Details

Gtk.InfoBar.signals.close(info_bar)
Signal Name:

close

Flags:

RUN_LAST, ACTION

Parameters:

info_bar (Gtk.InfoBar) – The object which received the signal

Gets emitted when the user uses a keybinding to dismiss the info bar.

The ::close signal is a keybinding signal.

The default binding for this signal is the Escape key.

Gtk.InfoBar.signals.response(info_bar, response_id)
Signal Name:

response

Flags:

RUN_LAST

Parameters:
  • info_bar (Gtk.InfoBar) – The object which received the signal

  • response_id (int) – the response ID

Emitted when an action widget is clicked.

The signal is also emitted when the application programmer calls [method`Gtk`.InfoBar.response]. The response_id depends on which action widget was clicked.

Property Details

Gtk.InfoBar.props.message_type
Name:

message-type

Type:

Gtk.MessageType

Default Value:

Gtk.MessageType.INFO

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

The type of the message.

The type may be used to determine the appearance of the info bar.

Gtk.InfoBar.props.revealed
Name:

revealed

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the info bar shows its contents.

Gtk.InfoBar.props.show_close_button
Name:

show-close-button

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

Whether to include a standard close button.