Gtk.AlertDialog

g GObject.Object GObject.Object Gtk.AlertDialog Gtk.AlertDialog GObject.Object->Gtk.AlertDialog

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

choose (parent, cancellable, callback, *user_data)

choose_finish (result)

get_buttons ()

get_cancel_button ()

get_default_button ()

get_detail ()

get_message ()

get_modal ()

set_buttons (labels)

set_cancel_button (button)

set_default_button (button)

set_detail (detail)

set_message (message)

set_modal (modal)

show (parent)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

buttons

[str]

r/w/en

cancel-button

int

r/w/en

default-button

int

r/w/en

detail

str

r/w/en

message

str

r/w/en

modal

bool

r/w/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.AlertDialog(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.AlertDialogClass

A GtkAlertDialog object collects the arguments that are needed to present a message to the user.

The message is shown with the [method`Gtk`.AlertDialog.choose] function. This API follows the GIO async pattern, and the result can be obtained by calling [method`Gtk`.AlertDialog.choose_finish].

If you don’t need to wait for a button to be clicked, you can use [method`Gtk`.AlertDialog.show].

New in version 4.10.

choose(parent, cancellable, callback, *user_data)[source]
Parameters:

This function shows the alert to the user.

The callback will be called when the alert is dismissed. It should call [method`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 [method`Gtk`.AlertDialog.show].

New in version 4.10.

choose_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

the index of the button that was clicked, or -1 if the dialog was cancelled and [property`Gtk`.AlertDialog:cancel-button] is not set

Return type:

int

Finishes the [method`Gtk`.AlertDialog.choose] call and returns the index of the button that was clicked.

New in version 4.10.

get_buttons()[source]
Returns:

the button labels

Return type:

[str] or None

Returns the button labels for the alert.

New in version 4.10.

get_cancel_button()[source]
Returns:

the index of the cancel button, or -1

Return type:

int

Returns the index of the cancel button.

New in version 4.10.

get_default_button()[source]
Returns:

the index of the default button, or -1

Return type:

int

Returns the index of the default button.

New in version 4.10.

get_detail()[source]
Returns:

the detail text

Return type:

str

Returns the detail text that will be shown in the alert.

New in version 4.10.

get_message()[source]
Returns:

the message

Return type:

str

Returns the message that will be shown in the alert.

New in version 4.10.

get_modal()[source]
Returns:

TRUE if the alert is modal

Return type:

bool

Returns whether the alert blocks interaction with the parent window while it is presented.

New in version 4.10.

set_buttons(labels)[source]
Parameters:

labels ([str]) – the new button labels

Sets the button labels for the alert.

New in version 4.10.

set_cancel_button(button)[source]
Parameters:

button (int) – the new cancel button

Sets the index of the cancel button.

See [property`Gtk`.AlertDialog:cancel-button] for details of how this value is used.

New in version 4.10.

set_default_button(button)[source]
Parameters:

button (int) – the new default button

Sets the index of the default button.

See [property`Gtk`.AlertDialog:default-button] for details of how this value is used.

New in version 4.10.

set_detail(detail)[source]
Parameters:

detail (str) – the new detail text

Sets the detail text that will be shown in the alert.

New in version 4.10.

set_message(message)[source]
Parameters:

message (str) – the new message

Sets the message that will be shown in the alert.

New in version 4.10.

set_modal(modal)[source]
Parameters:

modal (bool) – the new value

Sets whether the alert blocks interaction with the parent window while it is presented.

New in version 4.10.

show(parent)[source]
Parameters:

parent (Gtk.Window or None) – the parent GtkWindow

Show the alert to the user.

This function is a simple version of [method`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 Gio.Cancellable or callback respectively.

New in version 4.10.

Property Details

Gtk.AlertDialog.props.buttons
Name:

buttons

Type:

[str]

Default Value:

[]

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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.

New in version 4.10.

Gtk.AlertDialog.props.cancel_button
Name:

cancel-button

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`Gtk`.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.

New in version 4.10.

Gtk.AlertDialog.props.default_button
Name:

default-button

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`Gtk`.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.

New in version 4.10.

Gtk.AlertDialog.props.detail
Name:

detail

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The detail text for the alert.

New in version 4.10.

Gtk.AlertDialog.props.message
Name:

message

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The message for the alert.

New in version 4.10.

Gtk.AlertDialog.props.modal
Name:

modal

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the alert is modal.

New in version 4.10.