ColorButton#

Deprecated since version 4.10: Use ColorDialogButton instead

class ColorButton(**properties: Any)#

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ColorChooser, ConstraintTarget

The GtkColorButton 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]

GtkColorButton 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 ColorButton
classmethod new() Widget#

Creates a new color button.

This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color chooser dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.

Deprecated since version 4.10: Use ColorDialogButton instead

classmethod new_with_rgba(rgba: RGBA) Widget#

Creates a new color button showing the given color.

Parameters:

rgba – A GdkRGBA to set the current color with

Methods#

class ColorButton
get_modal() bool#

Gets whether the dialog is modal.

Deprecated since version 4.10: Use ColorDialogButton instead

get_title() str#

Gets the title of the color chooser dialog.

Deprecated since version 4.10: Use ColorDialogButton instead

set_modal(modal: bool) None#

Sets whether the dialog should be modal.

Deprecated since version 4.10: Use ColorDialogButton instead

Parameters:

modalTrue to make the dialog modal

set_title(title: str) None#

Sets the title for the color chooser dialog.

Deprecated since version 4.10: Use ColorDialogButton instead

Parameters:

title – String containing new window title

Properties#

class ColorButton
props.modal: bool#

Whether the color chooser dialog should be modal.

props.show_editor: bool#

Whether the color chooser should open in editor mode.

This property should be used in cases where the palette in the editor would be redundant, such as when the color button is already part of a palette.

props.title: str#

The title of the color chooser dialog

Signals#

class ColorButton.signals
activate() None#

Emitted to when the color button is activated.

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

Added in version 4.4.

color_set() None#

Emitted when the user selects a color.

When handling this signal, use get_rgba to find out which color was just selected.

Note that this signal is only emitted when the user changes the color. If you need to react to programmatic color changes as well, use the notify::rgba signal.