phoenix_title wx.ColourDatabase

wxWidgets maintains a database of standard RGB colours for a predefined set of named colours.

The application may add to this set if desired by using AddColour and may use it to look up colours by names using Find or find the names for the standard colour using FindName.

It is also possible to switch between the colour values defined in the CSS standard (see https://www.w3.org/TR/css-color-4/#named-colors) and the traditional colour values which were used by wxWidgets versions earlier than 3.3.0, which may be useful to preserve the appearance of the existing code: if you need to do this, please call UseScheme with Traditional argument, but the use of new, standard colours is recommended.

There is one predefined, global instance of this class called wx.TheColourDatabase .

The standard database contains at least the following colours:

AQUAMARINE

FIREBRICK

MEDIUM FOREST GREEN

RED

BLACK

FOREST GREEN

MEDIUM GOLDENROD

SALMON

BLUE

GOLD

MEDIUM ORCHID

SEA GREEN

BLUE VIOLET

GOLDENROD

MEDIUM SEA GREEN

SIENNA

BROWN

GREY

MEDIUM SLATE BLUE

SKY BLUE

CADET BLUE

GREEN

MEDIUM SPRING GREEN

SLATE BLUE

CORAL

GREEN YELLOW

MEDIUM TURQUOISE

SPRING GREEN

CORNFLOWER BLUE

INDIAN RED

MEDIUM VIOLET RED

STEEL BLUE

CYAN

KHAKI

MIDNIGHT BLUE

TAN

DARK GREY

LIGHT BLUE

NAVY

THISTLE

DARK GREEN

LIGHT GREY

ORANGE

TURQUOISE

DARK OLIVE GREEN

LIGHT STEEL BLUE

ORANGE RED

VIOLET

DARK ORCHID

LIME GREEN

ORCHID

VIOLET RED

DARK SLATE BLUE

MAGENTA

PALE GREEN

WHEAT

DARK SLATE GREY

MAROON

PINK

WHITE

DARK TURQUOISE

MEDIUM AQUAMARINE

PLUM

YELLOW

DIM GREY

MEDIUM BLUE

PURPLE

YELLOW GREEN


See the “Database colours” page of the Drawing Sample to see how all these colours look like.

See also

wx.Colour


class_hierarchy Class Hierarchy

Inheritance diagram for class ColourDatabase:

method_summary Methods Summary

__init__

Constructs the colour database.

AddColour

Adds a colour to the database.

Find

Finds a colour given the name.

FindColour

FindName

Finds a colour name given the colour.

GetAllNames

List all known colours by name.

UseScheme

Select the colour scheme to use.


property_summary Properties Summary

AllNames

See GetAllNames


api Class API

class wx.ColourDatabase(object)

Possible constructors:

ColourDatabase() -> None

wxWidgets maintains a database of standard RGB colours for a predefined set of named colours.


Methods

__init__(self)

Constructs the colour database.

It will be initialized at the first use.

Return type:

None



AddColour(self, colourName, colour)

Adds a colour to the database.

If a colour with the same name already exists, it is replaced.

Parameters:
Return type:

None



Find(self, colourName)

Finds a colour given the name.

Returns an invalid colour object (that is, wx.Colour.IsOk will return False) if the colour wasn’t found in the database.

Parameters:

colourName (string)

Return type:

wx.Colour



FindColour(self, colour)


FindName(self, colour)

Finds a colour name given the colour.

Returns an empty string if the colour is not found in the database.

Parameters:

colour (wx.Colour)

Return type:

str



GetAllNames(self)

List all known colours by name.

Return type:

VectorwxString

Added in version 4.3/wxWidgets-3.3.0.



UseScheme(self, scheme)

Select the colour scheme to use.

By default, wx.ColourDatabase uses CSS scheme which returns the standard values for the colours defined in the CSS specification, see https://www.w3.org/TR/css-color-4/#named-colors

If preserving compatibility with the behaviour and appearance of the previous wxWidgets versions is important, you may switch to the traditional colour scheme by using this function with Traditional argument, e.g. call

during the application initialization. Please note that in the previous versions wxGTK already used CSS colour values, unlike all the other ports, so Traditional is not actually backwards compatible for wxGTK, but does make the colour values consistent across all platforms and the same as had been used by wxMSW and wxOSX before. In other words, to obtain 100% compatibility with the previous versions, the UseScheme call above should be made for all ports except wxGTK.

Note that the colour names defined only by wxWidgets, which notably includes all colour variants with spaces in their names, are still available in the default CSS colour scheme, with their traditional values but the names of colours defined by CSS standard are taken from it, e.g. “wx.GREEN” corresponds to #00ff00 in the traditional scheme but to #008000 in the CSS scheme. Similarly, CSS colour names that were not defined by the previous wxWidgets versions are available even when using the traditional scheme, the scheme choice only affects the values of the colours defined by both wxWidgets and CSS with different values.

Parameters:

scheme (Scheme)

Return type:

None

Added in version 4.3/wxWidgets-3.3.0.


Properties

AllNames

See GetAllNames