Gtk.ColorButton

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ColorChooser Gtk.ColorChooser GObject.GInterface->Gtk.ColorChooser Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ColorButton Gtk.ColorButton Gtk.ColorChooser->Gtk.ColorButton Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Gtk.ColorButton

Example

../_images/ColorButton.png
Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.ColorChooser (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

class

new_with_rgba (rgba)

get_modal ()

get_title ()

set_modal (modal)

set_title (title)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.ColorChooser (4)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.ColorChooser (2)

Name

Type

Flags

Short Description

modal

bool

r/w/en

show-editor

bool

r/w/en

title

str

r/w

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1), Gtk.ColorChooser (1)

Name

Short Description

activate

Emitted to when the color button is activated.

color-set

Emitted when the user selects a color.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1), Gtk.ColorChooser (1)

Class Details

class Gtk.ColorButton(**kwargs)
Bases:

Gtk.Widget, Gtk.ColorChooser

Abstract:

No

The GtkColorButton allows to open a color chooser dialog to change the color.

An example Gtk.ColorButton

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.

Deprecated since version 4.10: Use [class`Gtk`.ColorDialogButton] instead

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 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 [class`Gtk`.ColorDialogButton] instead

classmethod new_with_rgba(rgba)[source]
Parameters:

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

Returns:

a new color button

Return type:

Gtk.Widget

Creates a new color button showing the given color.

get_modal()[source]
Returns:

True if the dialog is modal

Return type:

bool

Gets whether the dialog is modal.

Deprecated since version 4.10: Use [class`Gtk`.ColorDialogButton] instead

get_title()[source]
Returns:

An internal string, do not free the return value

Return type:

str

Gets the title of the color chooser dialog.

Deprecated since version 4.10: Use [class`Gtk`.ColorDialogButton] instead

set_modal(modal)[source]
Parameters:

modal (bool) – True to make the dialog modal

Sets whether the dialog should be modal.

Deprecated since version 4.10: Use [class`Gtk`.ColorDialogButton] instead

set_title(title)[source]
Parameters:

title (str) – String containing new window title

Sets the title for the color chooser dialog.

Deprecated since version 4.10: Use [class`Gtk`.ColorDialogButton] instead

Signal Details

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

activate

Flags:

RUN_FIRST, ACTION

Parameters:

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

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.

New in version 4.4.

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

Emitted when the user selects a color.

When handling this signal, use [method`Gtk`.ColorChooser.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.

Property Details

Gtk.ColorButton.props.modal
Name:

modal

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the color chooser dialog should be modal.

Gtk.ColorButton.props.show_editor
Name:

show-editor

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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.

Gtk.ColorButton.props.title
Name:

title

Type:

str

Default Value:

'Pick a Color'

Flags:

READABLE, WRITABLE

The title of the color chooser dialog