Gdk.Color

Fields

Name

Type

Access

Description

blue

int

r/w

The blue component of the color

green

int

r/w

The green component of the color

pixel

int

r/w

For allocated colors, the pixel value used to draw this color on the screen. Not used anymore.

red

int

r/w

The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensity

Methods

class

from_floats (red, green, blue)

class

parse (spec)

copy ()

equal (colorb)

free ()

hash ()

to_floats ()

to_string ()

Details

class Gdk.Color(red, green, blue)

A Gdk.Color is used to describe a color, similar to the XColor struct used in the X11 drawing API.

Deprecated since version 3.14: Use Gdk.RGBA

classmethod from_floats(red, green, blue)

Return a new Color object from red/green/blue values from 0.0 to 1.0.

classmethod parse(spec)[source]
Parameters

spec (str) – the string specifying the color

Returns

True if the parsing succeeded

color

the Gdk.Color to fill in

Return type

(bool, color: Gdk.Color)

Parses a textual specification of a color and fill in the red, green, and blue fields of a Gdk.Color.

The string can either one of a large set of standard names (taken from the X11 rgb.txt file), or it can be a hexadecimal value in the form “\#rgb” “\#rrggbb”, “\#rrrgggbbb” or “\#rrrrggggbbbb” where “r”, “g” and “b” are hex digits of the red, green, and blue components of the color, respectively. (White in the four forms is “\#fff”, “\#ffffff”, “\#fffffffff” and “\#ffffffffffff”).

Deprecated since version 3.14: Use Gdk.RGBA

copy()[source]
Returns

a copy of self

Return type

Gdk.Color

Makes a copy of a Gdk.Color.

The result must be freed using Gdk.Color.free().

Deprecated since version 3.14: Use Gdk.RGBA

equal(colorb)[source]
Parameters

colorb (Gdk.Color) – another Gdk.Color

Returns

True if the two colors compare equal

Return type

bool

Compares two colors.

Deprecated since version 3.14: Use Gdk.RGBA

free()[source]

Frees a Gdk.Color created with Gdk.Color.copy().

Deprecated since version 3.14: Use Gdk.RGBA

hash()[source]
Returns

The hash function applied to self

Return type

int

A hash function suitable for using for a hash table that stores Gdk.Colors.

Deprecated since version 3.14: Use Gdk.RGBA

to_floats()

Return (red_float, green_float, blue_float) triple.

to_string()[source]
Returns

a newly-allocated text string

Return type

str

Returns a textual specification of self in the hexadecimal form “\#rrrrggggbbbb” where “r”, “g” and “b” are hex digits representing the red, green and blue components respectively.

The returned string can be parsed by Gdk.Color.parse().

New in version 2.12.

Deprecated since version 3.14: Use Gdk.RGBA