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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See the “Database colours” page of the Drawing Sample to see how all these colours look like.
See also
Class Hierarchy¶
Inheritance diagram for class ColourDatabase:
Methods Summary¶Constructs the colour database. |
|
Adds a colour to the database. |
|
Finds a colour given the name. |
|
Finds a colour name given the colour. |
|
List all known colours by name. |
|
Select the colour scheme to use. |
Properties Summary¶See |
Class API¶Possible constructors:
ColourDatabase() -> None
wxWidgets maintains a database of standard RGB colours for a
predefined set of named colours.
Constructs the colour database.
It will be initialized at the first use.
None
Adds a colour to the database.
If a colour with the same name already exists, it is replaced.
colourName (string)
colour (wx.Colour)
None
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.
colourName (string)
Finds a colour name given the colour.
Returns an empty string if the colour is not found in the database.
colour (wx.Colour)
str
List all known colours by name.
VectorwxString
Added in version 4.3/wxWidgets-3.3.0.
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.
scheme (Scheme)
None
Added in version 4.3/wxWidgets-3.3.0.
See GetAllNames