:right-sidebar: True MessageDialog =================================================================== .. currentmodule:: gi.repository.Gtk .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.AlertDialog` instead .. class:: MessageDialog(*args, **kwargs) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Dialog`, :class:`~gi.repository.Gtk.Window`, :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Native`, :class:`~gi.repository.Gtk.Root`, :class:`~gi.repository.Gtk.ShortcutManager` ``GtkMessageDialog`` presents a dialog with some message text. .. image:: https://docs.gtk.org/gtk4/messagedialog.png 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 :const:`~gi.repository.Gtk.DialogFlags.MODAL` flag, which will call :obj:`~gi.repository.Gtk.Window.set_modal` internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the :obj:`~gi.repository.Gtk.Dialog.signals.response` signal to know when the user dismissed the dialog. An example for using a modal dialog: .. code-block:: :dedent: GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL; 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 (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL); You might do a non-modal ``GtkMessageDialog`` simply by omitting the :const:`~gi.repository.Gtk.DialogFlags.MODAL` flag: .. code-block:: :dedent: 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 (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL); GtkMessageDialog as GtkBuildable -------------------------------- The ``GtkMessageDialog`` implementation of the ``GtkBuildable`` interface exposes the message area as an internal child with the name “message_area”. Methods ------- .. rst-class:: interim-class .. class:: MessageDialog :no-index: .. method:: get_message_area() -> ~gi.repository.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 :obj:`~gi.repository.Gtk.Dialog.get_content_area` for the corresponding function in the parent :obj:`~gi.repository.Gtk.Dialog`. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.AlertDialog` instead .. method:: set_markup(str: str) -> None Sets the text of the message dialog. .. deprecated:: 4.10 Use :obj:`~gi.repository.Gtk.AlertDialog` instead :param str: string with Pango markup Properties ---------- .. rst-class:: interim-class .. class:: MessageDialog :no-index: .. attribute:: props.buttons :type: ~gi.repository.Gtk.ButtonsType .. attribute:: props.message_area :type: ~gi.repository.Gtk.Widget The ``GtkBox`` that corresponds to the message area of this dialog. See :obj:`~gi.repository.Gtk.MessageDialog.get_message_area` for a detailed description of this area. .. attribute:: props.message_type :type: ~gi.repository.Gtk.MessageType The type of the message. .. attribute:: props.secondary_text :type: str The secondary text of the message dialog. .. attribute:: props.secondary_use_markup :type: bool :const:`True` if the secondary text of the dialog includes Pango markup. See :obj:`~gi.repository.Pango.parse_markup`. .. attribute:: props.text :type: str The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title. .. attribute:: props.use_markup :type: bool :const:`True` if the primary text of the dialog includes Pango markup. See :obj:`~gi.repository.Pango.parse_markup`. Fields ------ .. rst-class:: interim-class .. class:: MessageDialog :no-index: .. attribute:: parent_instance