AlertDialog#
Added in version 4.10.
Superclasses: Object
Collects the arguments that are needed to present a message to the user.
The message is shown with the choose
function.
If you don’t need to wait for a button to be clicked, you can use
show.
Methods#
- class AlertDialog
- async choose(self, parent: Window | None = None) int#
This is the awaitable version of
choose().Added in version 4.10.
- Parameters:
parent – the parent window
- choose(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Shows the alert to the user.
It is ok to pass
NULLfor the callback if the alert does not have more than one button. A simpler API for this case isshow.Added in version 4.10.
- Parameters:
parent – the parent window
cancellable – a cancellable to cancel the operation
callback – a callback to call when the operation is complete
user_data – data to pass to
callback
- choose_finish(result: AsyncResult) int#
Finishes the
choosecall.Added in version 4.10.
- Parameters:
result – the result
- get_modal() bool#
Returns whether the alert blocks interaction with the parent window while it is presented.
Added in version 4.10.
- set_buttons(labels: list[str]) None#
Sets the button labels for the alert.
Added in version 4.10.
- Parameters:
labels – the new button labels
- set_cancel_button(button: int) None#
Sets the index of the cancel button.
See
cancel_buttonfor details of how this value is used.Added in version 4.10.
- Parameters:
button – the new cancel button
- set_default_button(button: int) None#
Sets the index of the default button.
See
default_buttonfor details of how this value is used.Added in version 4.10.
- Parameters:
button – the new default button
- set_detail(detail: str) None#
Sets the detail text that will be shown in the alert.
Added in version 4.10.
- Parameters:
detail – the new detail text
- set_message(message: str) None#
Sets the message that will be shown in the alert.
Added in version 4.10.
- Parameters:
message – the new message
- set_modal(modal: bool) None#
Sets whether the alert blocks interaction with the parent window while it is presented.
Added in version 4.10.
- Parameters:
modal – the new value
- show(parent: Window | None = None) None#
Shows the alert to the user.
This function is a simpler version of
chooseintended 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
Cancellableand callback respectively.Added in version 4.10.
- Parameters:
parent – the parent window
Properties#
- class AlertDialog
- props.buttons: 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.
Added in version 4.10.
- props.cancel_button: int#
Determines what happens when the Escape key is pressed while the alert is shown.
If this property holds the index of a button in
buttons, then pressing Escape is treated as if that button was pressed. If it is -1 or not a valid index for thebuttonsarray, then an error is returned.If
buttonsisNULL, then the automatically created ‘Close’ button is treated as both cancel and default button, so 0 is returned.Added in version 4.10.
- props.default_button: int#
Determines what happens when the Return key is pressed while the alert is shown.
If this property holds the index of a button in
buttons, then pressing Return is treated as if that button was pressed. If it is -1 or not a valid index for thebuttonsarray, then nothing happens.If
buttonsisNULL, then the automatically created ‘Close’ button is treated as both cancel and default button, so 0 is returned.Added in version 4.10.