ColorDialogButton

Added in version 4.10.

class ColorDialogButton(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

The GtkColorDialogButton is a wrapped around a ColorDialog and allows to open a color chooser dialog to change the color.

https://docs.gtk.org/gtk4/color-button.png

It is suitable widget for selecting a color in a preference dialog.

CSS nodes

colorbutton
╰── button.color
    ╰── [content]

GtkColorDialogButton has a single CSS node with name colorbutton which contains a button node. To differentiate it from a plain GtkButton, it gets the .color style class.

Constructors

class ColorDialogButton
classmethod new(dialog: ColorDialog | None = None) Widget

Creates a new GtkColorDialogButton with the given GtkColorDialog.

You can pass NULL to this function and set a GtkColorDialog later. The button will be insensitive until that happens.

Added in version 4.10.

Parameters:

dialog – the GtkColorDialog to use

Methods

class ColorDialogButton
get_dialog() ColorDialog | None

Returns the GtkColorDialog of self.

Added in version 4.10.

get_rgba() RGBA

Returns the color of the button.

This function is what should be used to obtain the color that was chosen by the user. To get informed about changes, listen to “notify::rgba”.

Added in version 4.10.

set_dialog(dialog: ColorDialog) None

Sets a GtkColorDialog object to use for creating the color chooser dialog that is presented when the user clicks the button.

Added in version 4.10.

Parameters:

dialog – the new GtkColorDialog

set_rgba(color: RGBA) None

Sets the color of the button.

Added in version 4.10.

Parameters:

color – the new color

Properties

class ColorDialogButton
props.dialog: ColorDialog

The GtkColorDialog that contains parameters for the color chooser dialog.

Added in version 4.10.

props.rgba: RGBA

The selected color.

This property can be set to give the button its initial color, and it will be updated to reflect the users choice in the color chooser dialog.

Listen to notify::rgba to get informed about changes to the buttons color.

Added in version 4.10.

Signals

class ColorDialogButton.signals
activate() None

Emitted when the color dialog button is activated.

The ::activate signal on GtkColorDialogButton is an action signal and emitting it causes the button to pop up its dialog.

Added in version 4.14.