Skip to content

Gtk.ColorDialog

class — extends GObject.Object

Asynchronous API to present a color chooser dialog.

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

The dialog is shown with the ColorDialog.choose_rgba function.

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

Constructors

new

@classmethod
def new(cls) -> ColorDialog

Creates a new GtkColorDialog object.

Methods

choose_rgba

def choose_rgba(self, parent: Window | None = ..., initial_color: Gdk.RGBA | None = ..., cancellable: Gio.Cancellable | None = ..., callback: Gio.AsyncReadyCallback | None = ...) -> None

Presents a color chooser dialog to the user.

Parameters:

  • parent — the parent window
  • initial_color — the color to select initially
  • cancellable — a cancellable to cancel the operation
  • callback — a callback to call when the operation is complete

choose_rgba_finish

def choose_rgba_finish(self, result: Gio.AsyncResult) -> Gdk.RGBA

Finishes the ColorDialog.choose_rgba call

Note that this function returns a DialogError.DISMISSED error if the user cancels the dialog.

Parameters:

  • result — the result

get_modal

def get_modal(self) -> bool

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

get_title

def get_title(self) -> str

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

get_with_alpha

def get_with_alpha(self) -> bool

Returns whether colors may have alpha.

set_modal

def set_modal(self, modal: bool) -> None

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

Parameters:

  • modal — the new value

set_title

def set_title(self, title: str) -> None

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

Parameters:

  • title — the new title

set_with_alpha

def set_with_alpha(self, with_alpha: bool) -> None

Sets whether colors may have alpha.

Parameters:

  • with_alpha — the new value

Properties

modal

modal: bool  # read/write

Whether the color chooser dialog is modal.

title

title: str  # read/write

A title that may be shown on the color chooser dialog.

with_alpha

with_alpha: bool  # read/write

Whether colors may have alpha (translucency).

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