Gtk.ColorChooser

g GObject.GInterface GObject.GInterface Gtk.ColorChooser Gtk.ColorChooser GObject.GInterface->Gtk.ColorChooser

Implementations:

Gtk.ColorButton, Gtk.ColorChooserDialog, Gtk.ColorChooserWidget

Methods

add_palette (orientation, colors_per_line, colors)

get_rgba ()

get_use_alpha ()

set_rgba (color)

set_use_alpha (use_alpha)

Virtual Methods

do_add_palette (orientation, colors_per_line, colors)

do_color_activated (color)

do_get_rgba ()

do_set_rgba (color)

Properties

Name

Type

Flags

Short Description

rgba

Gdk.RGBA

r/w

Current color, as a Gdk.RGBA

use-alpha

bool

r/w/en

Whether alpha should be shown

Signals

Name

Short Description

color-activated

Emitted when a color is activated from the color chooser.

Fields

None

Class Details

class Gtk.ColorChooser
Bases:

GObject.GInterface

Structure:

Gtk.ColorChooserInterface

Gtk.ColorChooser is an interface that is implemented by widgets for choosing colors. Depending on the situation, colors may be allowed to have alpha (translucency).

In GTK+, the main widgets that implement this interface are Gtk.ColorChooserWidget, Gtk.ColorChooserDialog and Gtk.ColorButton.

New in version 3.4.

add_palette(orientation, colors_per_line, colors)[source]
Parameters:

Adds a palette to the color chooser. If orientation is horizontal, the colors are grouped in rows, with colors_per_line colors in each row. If horizontal is False, the colors are grouped in columns instead.

The default color palette of Gtk.ColorChooserWidget has 27 colors, organized in columns of 3 colors. The default gray palette has 9 grays in a single row.

The layout of the color chooser widget works best when the palettes have 9-10 columns.

Calling this function for the first time has the side effect of removing the default color and gray palettes from the color chooser.

If colors is None, removes all previously added palettes.

New in version 3.4.

get_rgba()[source]
Returns:

a Gdk.RGBA to fill in with the current color

Return type:

color: Gdk.RGBA

Gets the currently-selected color.

New in version 3.4.

get_use_alpha()[source]
Returns:

True if the color chooser uses the alpha channel, False if not

Return type:

bool

Returns whether the color chooser shows the alpha channel.

New in version 3.4.

set_rgba(color)[source]
Parameters:

color (Gdk.RGBA) – the new color

Sets the color.

New in version 3.4.

set_use_alpha(use_alpha)[source]
Parameters:

use_alpha (bool) – True if color chooser should use alpha channel, False if not

Sets whether or not the color chooser should use the alpha channel.

New in version 3.4.

do_add_palette(orientation, colors_per_line, colors) virtual
Parameters:

Adds a palette to the color chooser. If orientation is horizontal, the colors are grouped in rows, with colors_per_line colors in each row. If horizontal is False, the colors are grouped in columns instead.

The default color palette of Gtk.ColorChooserWidget has 27 colors, organized in columns of 3 colors. The default gray palette has 9 grays in a single row.

The layout of the color chooser widget works best when the palettes have 9-10 columns.

Calling this function for the first time has the side effect of removing the default color and gray palettes from the color chooser.

If colors is None, removes all previously added palettes.

New in version 3.4.

do_color_activated(color) virtual
Parameters:

color (Gdk.RGBA) –

do_get_rgba() virtual
Returns:

a Gdk.RGBA to fill in with the current color

Return type:

color: Gdk.RGBA

Gets the currently-selected color.

New in version 3.4.

do_set_rgba(color) virtual
Parameters:

color (Gdk.RGBA) – the new color

Sets the color.

New in version 3.4.

Signal Details

Gtk.ColorChooser.signals.color_activated(color_chooser, color)
Signal Name:

color-activated

Flags:

RUN_FIRST

Parameters:

Emitted when a color is activated from the color chooser. This usually happens when the user clicks a color swatch, or a color is selected and the user presses one of the keys Space, Shift+Space, Return or Enter.

New in version 3.4.

Property Details

Gtk.ColorChooser.props.rgba
Name:

rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

The ::rgba property contains the currently selected color, as a Gdk.RGBA struct. The property can be set to change the current selection programmatically.

New in version 3.4.

Gtk.ColorChooser.props.use_alpha
Name:

use-alpha

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

When ::use-alpha is True, colors may have alpha (translucency) information. When it is False, the Gdk.RGBA struct obtained via the Gtk.ColorChooser :rgba property will be forced to have alpha == 1.

Implementations are expected to show alpha by rendering the color over a non-uniform background (like a checkerboard pattern).

New in version 3.4.