wx.Colour

Inheritance diagram for wx.Colour:



Description

A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values, and is used to determine drawing colours. See the entry for wx.ColourDatabase for how a pointer to a predefined, named colour may be returned instead of creating a new colour.

Valid RGB values are in the range 0 to 255.

You can retrieve the current system colour settings with wx.SystemSettings.

Derived From

Known Subclasses

wx.Color

Properties Summary

Class API

Methods

__init__(red=0, green=0, blue=0, alpha=wx.ALPHA_OPAQUE)

Constructs a colour from red, green, blue and alpha values.

Parameters:

  • red (byte)
  • green (byte)
  • blue (byte)
  • alpha (byte)

Returns:

wx.Colour


Alpha()

Returns the alpha value, on platforms where alpha is not yet supported, this always returns wx.ALPHA_OPAQUE.


Returns:

int


Blue()

Returns the blue intensity.


Returns:

int


Get(includeAlpha=False)

Returns the RGB intensity values as a tuple, optionally the alpha value as well.

Parameters:

  • includeAlpha (bool): whether to include the alpha bit in the output or not.

Returns:

(r, g, b) or (r, g, b, a)


GetAsString(flags=wx.C2S_NAME|wx.C2S_CSS_SYNTAX)

Returns the colour as a string.

Parameters:

  • flags (bool): Acceptable flags are:

    wx.C2S_NAME

    Returns colour name, when possible

    wx.C2S_CSS_SYNTAX

    Returns colour in rgb(r, g, b) syntax

    wx.C2S_HTML_SYNTAX

    Returns colour in #rrggbb syntax


Returns:

string


GetPixel()

Returns a pixel value which is platform-dependent. On Windows, a COLORREF is returned. On X, an allocated pixel value is returned.

-1 is returned if the pixel is invalid (on X, unallocated).


Returns:

int


GetRGB()

Returns the RGB intensity values as a tuple.


Returns:

(r, g, b)


Green()

Returns the green intensity.


Returns:

int


IsOk()

Returns True if the colour object is valid (the colour has been initialised with RGB values).


Returns:

int


Ok()

Synonim for IsOk.

Returns True if the colour object is valid (the colour has been initialised with RGB values).


Returns:

int


Red()

Returns the red intensity.


Returns:

int


Set(red, green, blue, alpha=wx.ALPHA_OPAQUE)

Sets the RGB intensity values.

Parameters:

  • red (int): The red intensity.
  • green (int): The green intensity.
  • blue (int): The blue intensity.
  • alpha (int): The alpha bit.

SetFromName(colourName)

Sets the RGB intensity values using a colour name listed in wx.TheColourDatabase.

Parameters:

  • colourName (string): The colour name.

SetRGB(colRGB)

Sets the RGB intensity values from a packed RGB value.

Parameters:

  • colRGB (tuple): The packed RGB values.

Properties

Pixel
See GetPixel
RGB
See GetRGB and SetRGB