Gtk.AlertDialog¶
class — extends GObject.Object
Collects the arguments that are needed to present a message to the user.
The message is shown with the AlertDialog.choose
function.
If you don't need to wait for a button to be clicked, you can use
AlertDialog.show.
Methods¶
choose¶
def choose(self, parent: Window | None = ..., cancellable: Gio.Cancellable | None = ..., callback: Gio.AsyncReadyCallback | 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 AlertDialog.show.
Parameters:
parent— the parent windowcancellable— a cancellable to cancel the operationcallback— a callback to call when the operation is complete
choose_finish¶
Finishes the AlertDialog.choose call.
Parameters:
result— the result
get_buttons¶
Returns the button labels for the alert.
get_cancel_button¶
Returns the index of the cancel button.
get_default_button¶
Returns the index of the default button.
get_detail¶
Returns the detail text that will be shown in the alert.
get_message¶
Returns the message that will be shown in the alert.
get_modal¶
Returns whether the alert blocks interaction with the parent window while it is presented.
set_buttons¶
Sets the button labels for the alert.
Parameters:
labels— the new button labels
set_cancel_button¶
Sets the index of the cancel button.
See AlertDialog.cancel-button for
details of how this value is used.
Parameters:
button— the new cancel button
set_default_button¶
Sets the index of the default button.
See AlertDialog.default-button for
details of how this value is used.
Parameters:
button— the new default button
set_detail¶
Sets the detail text that will be shown in the alert.
Parameters:
detail— the new detail text
set_message¶
Sets the message that will be shown in the alert.
Parameters:
message— the new message
set_modal¶
Sets whether the alert blocks interaction with the parent window while it is presented.
Parameters:
modal— the new value
show¶
Shows the alert to the user.
This function is a simpler version of 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
Gio.Cancellable and callback respectively.
Parameters:
parent— the parent window
Properties¶
buttons¶
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.
cancel_button¶
Determines what happens when the <kbd>Escape</kbd> key is pressed while the alert is shown.
If this property holds the index of a button in AlertDialog.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.
default_button¶
Determines what happens when the <kbd>Return</kbd> key is pressed while the alert is shown.
If this property holds the index of a button in AlertDialog.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.
detail¶
The detail text for the alert.
message¶
The message for the alert.
modal¶
Whether the alert is modal.