ColorDialog

Added in version 4.10.

class ColorDialog(**properties: Any)

Superclasses: Object

A GtkColorDialog object collects the arguments that are needed to present a color chooser dialog to the user, such as a title for the dialog and whether it should be modal.

The dialog is shown with the choose_rgba function. This API follows the GIO async pattern, and the result can be obtained by calling choose_rgba_finish.

See ColorDialogButton for a convenient control that uses GtkColorDialog and presents the results.

Constructors

class ColorDialog
classmethod new() ColorDialog

Creates a new GtkColorDialog object.

Added in version 4.10.

Methods

class ColorDialog
choose_rgba(parent: Window | None = None, initial_color: RGBA | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

This function initiates a color choice operation by presenting a color chooser dialog to the user.

The callback will be called when the dialog is dismissed. It should call choose_rgba_finish to obtain the result.

Added in version 4.10.

Parameters:
  • parent – the parent GtkWindow

  • initial_color – the color to select initially

  • cancellable – a GCancellable to cancel the operation

  • callback – a callback to call when the operation is complete

  • user_data – data to pass to callback

choose_rgba_finish(result: AsyncResult) RGBA | None

Finishes the choose_rgba call and returns the resulting color.

Added in version 4.10.

Parameters:

result – a GAsyncResult

get_modal() bool

Returns whether the color chooser dialog blocks interaction with the parent window while it is presented.

Added in version 4.10.

get_title() str

Returns the title that will be shown on the color chooser dialog.

Added in version 4.10.

get_with_alpha() bool

Returns whether colors may have alpha.

Added in version 4.10.

set_modal(modal: bool) None

Sets whether the color chooser dialog blocks interaction with the parent window while it is presented.

Added in version 4.10.

Parameters:

modal – the new value

set_title(title: str) None

Sets the title that will be shown on the color chooser dialog.

Added in version 4.10.

Parameters:

title – the new title

set_with_alpha(with_alpha: bool) None

Sets whether colors may have alpha.

Added in version 4.10.

Parameters:

with_alpha – the new value

Properties

class ColorDialog
props.modal: bool

Whether the color chooser dialog is modal.

Added in version 4.10.

props.title: str

A title that may be shown on the color chooser dialog that is presented by choose_rgba.

Added in version 4.10.

props.with_alpha: bool

Whether colors may have alpha (translucency).

When with-alpha is False, the color that is selected will be forced to have alpha == 1.

Added in version 4.10.