Gtk.MessageDialog

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 Gtk.Native Gtk.Native GObject.GInterface->Gtk.Native Gtk.Root Gtk.Root GObject.GInterface->Gtk.Root Gtk.ShortcutManager Gtk.ShortcutManager GObject.GInterface->Gtk.ShortcutManager 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.Dialog Gtk.Dialog Gtk.MessageDialog Gtk.MessageDialog Gtk.Dialog->Gtk.MessageDialog Gtk.Window Gtk.Window Gtk.Native->Gtk.Window Gtk.Root->Gtk.Window Gtk.ShortcutManager->Gtk.Window Gtk.Widget->Gtk.Window Gtk.Window->Gtk.Dialog

Example

../_images/MessageDialog.png
Subclasses:

None

Methods

Inherited:

Gtk.Dialog (11), Gtk.Window (62), Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Native (6), Gtk.Root (3)

Structs:

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

get_message_area ()

set_markup (str)

Virtual Methods

Inherited:

Gtk.Dialog (2), Gtk.Window (5), Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.ShortcutManager (2)

Properties

Inherited:

Gtk.Dialog (1), Gtk.Window (25), Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

buttons

Gtk.ButtonsType

w/co

message-area

Gtk.Widget

r

message-type

Gtk.MessageType

r/w/c/en

secondary-text

str

r/w

secondary-use-markup

bool

r/w/en

text

str

r/w

use-markup

bool

r/w/en

Signals

Inherited:

Gtk.Dialog (2), Gtk.Window (5), Gtk.Widget (13), GObject.Object (1)

Fields

Inherited:

Gtk.Dialog (2), Gtk.Window (5), Gtk.Widget (13), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.Dialog

r

Class Details

class Gtk.MessageDialog(*args, **kwargs)
Bases:

Gtk.Dialog

Abstract:

No

Structure:

Gtk.MessageDialogClass

GtkMessageDialog presents a dialog with some message text.

An example Gtk.MessageDialog

It’s simply a convenience widget; you could construct the equivalent of GtkMessageDialog from GtkDialog without too much effort, but GtkMessageDialog saves typing.

The easiest way to do a modal message dialog is to use the Gtk.DialogFlags.MODAL flag, which will call [method`Gtk`.Window.set_modal] internally. The dialog will prevent interaction with the parent window until it’s hidden or destroyed. You can use the [signal`Gtk`.Dialog::response] signal to know when the user dismissed the dialog.

An example for using a modal dialog: ```c Gtk.DialogFlags flags = Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL; dialog = gtk_message_dialog_new (parent_window, flags, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, “Error reading “%s”: %s”, filename, GLib.strerror (errno)); // Destroy the dialog when the user responds to it // (e.g. clicks a button)

g_signal_connect (dialog, “response”, G_CALLBACK (Gtk.Window.destroy), None); ```

You might do a non-modal GtkMessageDialog simply by omitting the Gtk.DialogFlags.MODAL flag:

```c Gtk.DialogFlags flags = Gtk.DialogFlags.DESTROY_WITH_PARENT; dialog = gtk_message_dialog_new (parent_window, flags, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, “Error reading “%s”: %s”, filename, GLib.strerror (errno));

// Destroy the dialog when the user responds to it // (e.g. clicks a button) g_signal_connect (dialog, “response”, G_CALLBACK (Gtk.Window.destroy), None); ```

Gtk.MessageDialog as Gtk.Buildable

The GtkMessageDialog implementation of the GtkBuildable interface exposes the message area as an internal child with the name “message_area”.

Deprecated since version 4.10: Use [class`Gtk`.AlertDialog] instead

get_message_area()[source]
Returns:

A GtkBox corresponding to the “message area” in the self

Return type:

Gtk.Widget

Returns the message area of the dialog.

This is the box where the dialog’s primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those labels. See [method`Gtk`.Dialog.get_content_area] for the corresponding function in the parent [class`Gtk`.Dialog].

Deprecated since version 4.10: Use [class`Gtk`.AlertDialog] instead

set_markup(str)[source]
Parameters:

str (str) – string with Pango markup

Sets the text of the message dialog.

Deprecated since version 4.10: Use [class`Gtk`.AlertDialog] instead

Property Details

Gtk.MessageDialog.props.buttons
Name:

buttons

Type:

Gtk.ButtonsType

Default Value:

Gtk.ButtonsType.NONE

Flags:

WRITABLE, CONSTRUCT_ONLY

Gtk.MessageDialog.props.message_area
Name:

message-area

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE

The GtkBox that corresponds to the message area of this dialog.

See [method`Gtk`.MessageDialog.get_message_area] for a detailed description of this area.

Gtk.MessageDialog.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.

Gtk.MessageDialog.props.secondary_text
Name:

secondary-text

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The secondary text of the message dialog.

Gtk.MessageDialog.props.secondary_use_markup
Name:

secondary-use-markup

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

True if the secondary text of the dialog includes Pango markup.

See [func`Pango`.parse_markup].

Gtk.MessageDialog.props.text
Name:

text

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE

The primary text of the message dialog.

If the dialog has a secondary text, this will appear as the title.

Gtk.MessageDialog.props.use_markup
Name:

use-markup

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

True if the primary text of the dialog includes Pango markup.

See [func`Pango`.parse_markup].