Package wx :: Class Colour
[frames | no frames]

Type Colour

object --+    
         |    
    Object --+
             |
            Colour

Known Subclasses:
Colour

A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values, and is used to determine drawing colours, window colours, etc. Valid RGB values are in the range 0 to 255.

In wxPython there are typemaps that will automatically convert from a colour name, from a '#RRGGBB' colour hex value string, or from a 3 or 4 integer tuple to a wx.Colour object when calling C++ methods that expect a wxColour. This means that the following are all equivallent:

win.SetBackgroundColour(wxColour(0,0,255))
win.SetBackgroundColour('BLUE')
win.SetBackgroundColour('#0000FF')
win.SetBackgroundColour((0,0,255))

Additional colour names and their coresponding values can be added using wx.ColourDatabase. Various system colours (as set in the user's system preferences) can be retrieved with wx.SystemSettings.GetColour.


Method Summary
Colour __init__(self, red, green, blue, alpha)
Constructs a colour from red, green, blue and alpha values.
  __del__(self)
bool __eq__(self, other)
Compare colours for equality.
  __getitem__(self, index)
  __len__(self)
bool __ne__(self, other)
Compare colours for inequality.
  __nonzero__(self)
  __reduce__(self)
  __repr__(self)
  __str__(self)
byte Alpha(self)
Returns the Alpha value.
  asTuple(*args, **kwargs)
asTuple is deprecated, use Get instead
byte Blue(self)
Returns the blue intensity.
(r,g,b) or (r,g,b,a) Get(self, includeAlpha)
Returns the RGB intensity values as a tuple, optionally the alpha value as well.
String GetAsString(self, flags)
Return the colour as a string.
long GetPixel(self)
Returns a pixel value which is platform-dependent.
unsigned long GetRGB(self)
Return the colour as a packed RGB value
byte Green(self)
Returns the green intensity.
bool IsOk(self)
Returns True if the colour object is valid (the colour has been initialised with RGB values).
bool Ok(self)
Returns True if the colour object is valid (the colour has been initialised with RGB values).
byte Red(self)
Returns the red intensity.
  Set(self, red, green, blue, alpha)
Sets the RGB intensity values.
  SetFromName(self, colourName)
Sets the RGB intensity values using a colour name listed in wx.TheColourDatabase.
  SetRGB(*args, **kwargs)
SetRGB(self, unsigned long colRGB)

Property Summary
  Pixel: See GetPixel
  RGB: See GetRGB and SetRGB
  thisown: The membership flag

Class Variable Summary
bool __safe_for_unpickling__ = True

Method Details

__init__(self, red=0, green=0, blue=0, alpha=ALPHA_OPAQUE)
(Constructor)

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

Parameters:
red
           (type=byte)

green
           (type=byte)

blue
           (type=byte)

alpha
           (type=byte)

Returns:
Colour
Overrides:
wx.Object.__init__

See Also:

Alternate constructors wx.NamedColour and wx.ColourRGB.

__eq__(self, other)
(Equality operator)

Compare colours for equality.

Parameters:
other
           (type=PyObject)

Returns:
bool

__ne__(self, other)

Compare colours for inequality.

Parameters:
other
           (type=PyObject)

Returns:
bool

Alpha(self)

Returns the Alpha value.

Returns:
byte

asTuple(*args, **kwargs)

asTuple is deprecated, use Get instead

Blue(self)

Returns the blue intensity.

Returns:
byte

Get(self, includeAlpha=False)

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

Parameters:
includeAlpha
           (type=bool)

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

GetAsString(self, flags=wxC2S_NAME|wxC2S_CSS_SYNTAX)

Return the colour as a string. Acceptable flags are:

wx.C2S_NAME return colour name, when possible
wx.C2S_CSS_SYNTAX return colour in rgb(r,g,b) syntax
wx.C2S_HTML_SYNTAX return colour in #rrggbb syntax
Parameters:
flags
           (type=long)

Returns:
String

GetPixel(self)

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:
long

GetRGB(self)

Return the colour as a packed RGB value

Returns:
unsigned long

Green(self)

Returns the green intensity.

Returns:
byte

IsOk(self)

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

Returns:
bool

Ok(self)

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

Returns:
bool

Red(self)

Returns the red intensity.

Returns:
byte

Set(self, red, green, blue, alpha=ALPHA_OPAQUE)

Sets the RGB intensity values.

Parameters:
red
           (type=byte)

green
           (type=byte)

blue
           (type=byte)

alpha
           (type=byte)

SetFromName(self, colourName)

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

Parameters:
colourName
           (type=String)

SetRGB(*args, **kwargs)

SetRGB(self, unsigned long colRGB)

Sets the RGB intensity values from a packed RGB value.


Property Details

Pixel

See GetPixel

Get Method:
GetPixel(self)

RGB

See GetRGB and SetRGB

Get Method:
GetRGB(self)
Set Method:
SetRGB(*args, **kwargs)

thisown

The membership flag


Class Variable Details

__safe_for_unpickling__

Type:
bool
Value:
True                                                                   

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:53:44 2009 http://epydoc.sf.net