: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` 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(self, parent: ~gi.repository.Gtk.Window | None = None) -> int :async: This is the `awaitable `_ version of :meth:`choose`. .. versionadded:: 4.10 :param parent: the parent window .. method:: choose(parent: ~gi.repository.Gtk.Window | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~collections.abc.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None 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 window :param cancellable: a cancellable 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. .. versionadded:: 4.10 :param result: the result .. 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 Shows the alert to the user. This function is a simpler 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` and callback respectively. .. versionadded:: 4.10 :param parent: the parent window Properties ---------- .. rst-class:: interim-class .. class:: AlertDialog :no-index: .. attribute:: props.buttons :type: list[str] Labels for buttons to show in the alert. The labels should be translated and may contain a ``_`` character to indicate the mnemonic character. If this property is not set, then a 'Close' button is automatically created. .. versionadded:: 4.10 .. attribute:: props.cancel_button :type: int Determines what happens when the :kbd:`Escape` key is pressed while the alert is shown. If this property holds the index of a button in :obj:`~gi.repository.Gtk.AlertDialog.props.buttons`\, then pressing Escape is treated as if that button was pressed. If it is -1 or not a valid index for the ``buttons`` array, then an error is returned. If ``buttons`` is ``NULL``\, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned. .. versionadded:: 4.10 .. attribute:: props.default_button :type: int Determines what happens when the :kbd:`Return` key is pressed while the alert is shown. If this property holds the index of a button in :obj:`~gi.repository.Gtk.AlertDialog.props.buttons`\, then pressing Return is treated as if that button was pressed. If it is -1 or not a valid index for the ``buttons`` array, then nothing happens. If ``buttons`` is ``NULL``\, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned. .. versionadded:: 4.10 .. attribute:: props.detail :type: str The detail text for the alert. .. versionadded:: 4.10 .. attribute:: props.message :type: str The message for the alert. .. versionadded:: 4.10 .. attribute:: props.modal :type: bool Whether the alert is modal. .. versionadded:: 4.10