Gtk.MessageDialog¶
Example¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Dialog (14), Gtk.Window (119), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Gtk.Dialog (1), Gtk.Window (33), Gtk.Container (3), Gtk.Widget (39)
Name |
Type |
Flags |
Short Description |
---|---|---|---|
w/co |
The buttons shown in the message dialog |
||
d/r/w |
The image |
||
r |
|
||
r/w/c/en |
The type of message |
||
r/w |
The secondary text of the message dialog |
||
r/w/en |
The secondary text includes Pango markup. |
||
r/w |
The primary text of the message dialog |
||
r/w/en |
The primary text of the title includes Pango markup. |
Style Properties¶
- Inherited:
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
|
r |
Width of border around the label in the message dialog |
Signals¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.MessageDialog(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Gtk.MessageDialog
presents a dialog with some message text. It’s simply a convenience widget; you could construct the equivalent ofGtk.MessageDialog
fromGtk.Dialog
without too much effort, butGtk.MessageDialog
saves typing.One difference from
Gtk.Dialog
is thatGtk.MessageDialog
sets theGtk.Window
:skip-taskbar-hint
property toTrue
, so that the dialog is hidden from the taskbar by default.The easiest way to do a modal message dialog is to use
Gtk.Dialog.run
(), though you can also pass in theGtk.DialogFlags.MODAL
flag,Gtk.Dialog.run
() automatically makes the dialog modal and waits for the user to respond to it.Gtk.Dialog.run
() returns when any dialog button is clicked.An example for using a modal dialog:
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; dialog = gtk_message_dialog_new (parent_window, flags, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error reading “%s”: %s", filename, g_strerror (errno)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog);
You might do a non-modal
Gtk.MessageDialog
as follows:An example for a non-modal dialog:
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; dialog = gtk_message_dialog_new (parent_window, flags, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error reading “%s”: %s", filename, g_strerror (errno)); // Destroy the dialog when the user responds to it // (e.g. clicks a button) g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
The
Gtk.MessageDialog
implementation of theGtk.Buildable
interface exposes the message area as an internal child with the name “message_area”.- format_secondary_markup(message_format)[source]¶
Sets the secondary text of the message dialog to be message_format (with printf()-style), which is marked up with the Pango text markup language.
Due to an oversight, this function does not escape special XML characters like gtk_message_dialog_new_with_markup() does. Thus, if the arguments may contain special XML characters, you should use g_markup_printf_escaped() to escape it.
gchar *msg; msg = g_markup_printf_escaped (message_format, ...); gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg); g_free (msg);
New in version 2.6.
- format_secondary_text(message_format)[source]¶
Sets the secondary text of the message dialog to be message_format (with printf()-style).
New in version 2.6.
- get_image()[source]¶
- Returns:
the dialog’s image
- Return type:
Gets the dialog’s image.
New in version 2.14.
Deprecated since version 3.12: Use
Gtk.Dialog
for dialogs with images
- get_message_area()[source]¶
- Returns:
A
Gtk.Box
corresponding to the “message area” in the self.- Return type:
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
Gtk.Dialog.get_content_area
() for the corresponding function in the parentGtk.Dialog
.New in version 2.22.
- set_image(image)[source]¶
- Parameters:
image (
Gtk.Widget
) – the image
Sets the dialog’s image to image.
New in version 2.10.
Deprecated since version 3.12: Use
Gtk.Dialog
to create dialogs with images
- set_markup(str)[source]¶
- Parameters:
str (
str
) – markup string (see Pango markup format)
Sets the text of the message dialog to be str, which is marked up with the Pango text markup language.
New in version 2.4.
Property Details¶
- Gtk.MessageDialog.props.buttons¶
- Name:
buttons
- Type:
- Default Value:
- Flags:
The buttons shown in the message dialog
- Gtk.MessageDialog.props.image¶
- Name:
image
- Type:
- Default Value:
- Flags:
The image for this dialog.
New in version 2.10.
Deprecated since version 3.12: Use
Gtk.Dialog
to create dialogs with images
- Gtk.MessageDialog.props.message_area¶
- Name:
message-area
- Type:
- Default Value:
- Flags:
The
Gtk.Box
that corresponds to the message area of this dialog. SeeGtk.MessageDialog.get_message_area
() for a detailed description of this area.New in version 2.22.
- Gtk.MessageDialog.props.message_type¶
- Name:
message-type
- Type:
- Default Value:
- Flags:
The type of the message.
- Gtk.MessageDialog.props.secondary_text¶
-
The secondary text of the message dialog.
New in version 2.10.
- Gtk.MessageDialog.props.secondary_use_markup¶
- Name:
secondary-use-markup
- Type:
- Default Value:
- Flags:
True
if the secondary text of the dialog includes Pango markup. SeePango.parse_markup
().New in version 2.10.
- Gtk.MessageDialog.props.text¶
-
The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.
New in version 2.10.
- Gtk.MessageDialog.props.use_markup¶
- Name:
use-markup
- Type:
- Default Value:
- Flags:
True
if the primary text of the dialog includes Pango markup. SeePango.parse_markup
().New in version 2.10.