:right-sidebar: True AlertDialog =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.10 .. class:: AlertDialog(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkAlertDialog`` object collects the arguments that are needed to present a message to the user. The message is shown with the :obj:`~gi.repository.Gtk.AlertDialog.choose` function. If you don't need to wait for a button to be clicked, you can use :obj:`~gi.repository.Gtk.AlertDialog.show`\. Methods ------- .. rst-class:: interim-class .. class:: AlertDialog :no-index: .. method:: choose(parent: ~gi.repository.Gtk.Window | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None This function shows the alert to the user. It is ok to pass ``NULL`` for the callback if the alert does not have more than one button. A simpler API for this case is :obj:`~gi.repository.Gtk.AlertDialog.show`\. .. versionadded:: 4.10 :param parent: the parent ``GtkWindow`` :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: choose_finish(result: ~gi.repository.Gio.AsyncResult) -> int Finishes the :obj:`~gi.repository.Gtk.AlertDialog.choose` call and returns the index of the button that was clicked. .. versionadded:: 4.10 :param result: a ``GAsyncResult`` .. method:: get_buttons() -> list[str] | None Returns the button labels for the alert. .. versionadded:: 4.10 .. method:: get_cancel_button() -> int Returns the index of the cancel button. .. versionadded:: 4.10 .. method:: get_default_button() -> int Returns the index of the default button. .. versionadded:: 4.10 .. method:: get_detail() -> str Returns the detail text that will be shown in the alert. .. versionadded:: 4.10 .. method:: get_message() -> str Returns the message that will be shown in the alert. .. versionadded:: 4.10 .. method:: get_modal() -> bool Returns whether the alert blocks interaction with the parent window while it is presented. .. versionadded:: 4.10 .. method:: set_buttons(labels: list[str]) -> None Sets the button labels for the alert. .. versionadded:: 4.10 :param labels: the new button labels .. method:: set_cancel_button(button: int) -> None Sets the index of the cancel button. See :obj:`~gi.repository.Gtk.AlertDialog.props.cancel_button` for details of how this value is used. .. versionadded:: 4.10 :param button: the new cancel button .. method:: set_default_button(button: int) -> None Sets the index of the default button. See :obj:`~gi.repository.Gtk.AlertDialog.props.default_button` for details of how this value is used. .. versionadded:: 4.10 :param button: the new default button .. method:: set_detail(detail: str) -> None Sets the detail text that will be shown in the alert. .. versionadded:: 4.10 :param detail: the new detail text .. method:: set_message(message: str) -> None Sets the message that will be shown in the alert. .. versionadded:: 4.10 :param message: the new message .. method:: set_modal(modal: bool) -> None Sets whether the alert blocks interaction with the parent window while it is presented. .. versionadded:: 4.10 :param modal: the new value .. method:: show(parent: ~gi.repository.Gtk.Window | None = None) -> None Show the alert to the user. This function is a simple version of :obj:`~gi.repository.Gtk.AlertDialog.choose` intended for dialogs with a single button. If you want to cancel the dialog or if the alert has more than one button, you should use that function instead and provide it with a :obj:`~gi.repository.Gio.Cancellable` or callback respectively. .. versionadded:: 4.10 :param parent: the parent ``GtkWindow`` Properties ---------- .. rst-class:: interim-class .. class:: AlertDialog :no-index: .. attribute:: props.buttons :type: list[str] The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.cancel_button :type: int The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.default_button :type: int The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.detail :type: str The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.message :type: str The type of the None singleton. .. versionadded:: 4.10 .. attribute:: props.modal :type: bool The type of the None singleton. .. versionadded:: 4.10