: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` :Constructors: :: AlertDialog(**properties) 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[[...], None] | None = None, *user_data: ~typing.Any) -> None This function shows the alert to the user. The ``callback`` will be called when the alert is dismissed. It should call :obj:`~gi.repository.Gtk.AlertDialog.choose_finish` to obtain the result. 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: ~typing.Sequence[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: ~typing.Sequence[str] Labels for buttons to show in the alert. The labels should be translated and may contain a _ 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 This property determines what happens when the 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 This property determines what happens when the 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