Gtk.ColorButton

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Activatable Gtk.Activatable GObject.GInterface->Gtk.Activatable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ColorChooser Gtk.ColorChooser GObject.GInterface->Gtk.ColorChooser GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Button Gtk.Button Gtk.Actionable->Gtk.Button Gtk.Activatable->Gtk.Button Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.Button Gtk.Buildable->Gtk.Widget Gtk.ColorButton Gtk.ColorButton Gtk.Button->Gtk.ColorButton Gtk.ColorChooser->Gtk.ColorButton Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget->Gtk.Container

Example

../_images/ColorButton.png
Subclasses:

None

Methods

Inherited:

Gtk.Button (29), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Actionable (5), Gtk.Activatable (6), Gtk.ColorChooser (5)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

class

new_with_color (color)

class

new_with_rgba (rgba)

get_alpha ()

get_color ()

get_title ()

get_use_alpha ()

set_alpha (alpha)

set_color (color)

set_title (title)

set_use_alpha (use_alpha)

Virtual Methods

Inherited:

Gtk.Button (6), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Actionable (4), Gtk.Activatable (2), Gtk.ColorChooser (4)

do_color_set ()

Properties

Inherited:

Gtk.Button (9), Gtk.Container (3), Gtk.Widget (39), Gtk.Actionable (2), Gtk.Activatable (2), Gtk.ColorChooser (2)

Name

Type

Flags

Short Description

alpha

int

r/w

The selected opacity value (0 fully transparent, 65535 fully opaque)

color

Gdk.Color

d/r/w

The selected color deprecated

show-editor

bool

r/w/en

Whether to show the color editor right away

title

str

r/w

The title of the color selection dialog

Style Properties

Inherited:

Gtk.Button (7), Gtk.Widget (17)

Signals

Inherited:

Gtk.Button (6), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.ColorChooser (1)

Name

Short Description

color-set

The ::color-set signal is emitted when the user selects a color.

Fields

Inherited:

Gtk.Button (6), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.ColorChooser (1)

Name

Type

Access

Description

button

Gtk.Button

r

Class Details

class Gtk.ColorButton(*args, **kwargs)
Bases:

Gtk.Button, Gtk.ColorChooser

Abstract:

No

Structure:

Gtk.ColorButtonClass

The Gtk.ColorButton is a button which displays the currently selected color and allows to open a color selection dialog to change the color. It is suitable widget for selecting a color in a preference dialog.

CSS nodes

Gtk.ColorButton has a single CSS node with name button. To differentiate it from a plain Gtk.Button, it gets the .color style class.

classmethod new()[source]
Returns:

a new color button

Return type:

Gtk.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-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.

New in version 2.4.

classmethod new_with_color(color)[source]
Parameters:

color (Gdk.Color) – A Gdk.Color to set the current color with

Returns:

a new color button

Return type:

Gtk.Widget

Creates a new color button.

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorButton.new_with_rgba() instead.

classmethod new_with_rgba(rgba)[source]
Parameters:

rgba (Gdk.RGBA) – A Gdk.RGBA to set the current color with

Returns:

a new color button

Return type:

Gtk.Widget

Creates a new color button.

New in version 3.0.

get_alpha()[source]
Returns:

an integer between 0 and 65535

Return type:

int

Returns the current alpha value.

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorChooser.get_rgba() instead.

get_color()[source]
Returns:

a Gdk.Color to fill in with the current color

Return type:

color: Gdk.Color

Sets color to be the current color in the Gtk.ColorButton widget.

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorChooser.get_rgba() instead.

get_title()[source]
Returns:

An internal string, do not free the return value

Return type:

str

Gets the title of the color selection dialog.

New in version 2.4.

get_use_alpha()[source]
Returns:

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

Return type:

bool

Does the color selection dialog use the alpha channel ?

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorChooser.get_use_alpha() instead.

set_alpha(alpha)[source]
Parameters:

alpha (int) – an integer between 0 and 65535

Sets the current opacity to be alpha.

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorChooser.set_rgba() instead.

set_color(color)[source]
Parameters:

color (Gdk.Color) – A Gdk.Color to set the current color with

Sets the current color to be color.

New in version 2.4.

Deprecated since version ???: Use Gtk.ColorChooser.set_rgba() instead.

set_title(title)[source]
Parameters:

title (str) – String containing new window title

Sets the title for the color selection dialog.

New in version 2.4.

set_use_alpha(use_alpha)[source]
Parameters:

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

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

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorChooser.set_use_alpha() instead.

do_color_set() virtual

Signal Details

Gtk.ColorButton.signals.color_set(color_button)
Signal Name:

color-set

Flags:

RUN_FIRST

Parameters:

color_button (Gtk.ColorButton) – The object which received the signal

The ::color-set signal is emitted when the user selects a color. When handling this signal, use gtk_color_button_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::color signal.

New in version 2.4.

Property Details

Gtk.ColorButton.props.alpha
Name:

alpha

Type:

int

Default Value:

65535

Flags:

READABLE, WRITABLE

The selected opacity value (0 fully transparent, 65535 fully opaque).

New in version 2.4.

Gtk.ColorButton.props.color
Name:

color

Type:

Gdk.Color

Default Value:

None

Flags:

DEPRECATED, READABLE, WRITABLE

The selected color.

New in version 2.4.

Deprecated since version 3.4: Use Gtk.ColorButton :rgba instead.

Gtk.ColorButton.props.show_editor
Name:

show-editor

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Set this property to True to skip the palette in the dialog and go directly to the color editor.

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.

New in version 3.20.

Gtk.ColorButton.props.title
Name:

title

Type:

str

Default Value:

'Pick a Color'

Flags:

READABLE, WRITABLE

The title of the color selection dialog

New in version 2.4.