Type Colour
object
--+
|
Object
--+
|
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, or from a '#RRGGBB' colour hex value string 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')
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)
Constructs a colour from red, green and blue values. |
|
__del__(self)
|
bool |
__eq__ (self,
colour)
Compare colours for equality |
bool |
__ne__ (self,
colour)
Compare colours for inequality |
|
__nonzero__(self)
|
|
__reduce__(self)
|
|
__repr__(self)
|
|
__str__(self)
|
|
asTuple (*args,
**kwargs)
asTuple is deprecated, use Get instead |
byte |
Blue (self)
Returns the blue intensity. |
(r, g, b) |
Get ()
Returns the RGB intensity values as a tuple. |
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 |
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)
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) |
__init__(self,
red=0,
green=0,
blue=0)
(Constructor)
Constructs a colour from red, green and blue values. -
- Parameters:
red
(type=byte)
green
(type=byte)
blue
(type=byte)
- Returns:
-
Colour
- Overrides:
wx.Object.__init__
See Also: Alternate constructors wx.NamedColour and wx.ColourRGB .
|
__eq__(self,
colour)
(Equality operator)
Compare colours for equality -
- Parameters:
colour
(type=Colour)
- Returns:
-
bool
|
__ne__(self,
colour)
Compare colours for inequality -
- Parameters:
colour
(type=Colour)
- Returns:
-
bool
|
asTuple(*args,
**kwargs)
asTuple is deprecated, use Get instead -
|
Blue(self)
Returns the blue intensity. -
- Returns:
-
byte
|
Get()
Returns the RGB intensity values as a tuple. -
- Returns:
-
(r, g, b)
|
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
|
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)
Sets the RGB intensity values. -
- Parameters:
red
(type=byte)
green
(type=byte)
blue
(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.
-
|
__safe_for_unpickling__
-
- Type:
-
bool
- Value:
|