.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.ColourDatabase:

==========================================================================================================================================
|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 :meth:`~wx.ColourDatabase.AddColour`  and may use it to look up colours by names using :meth:`~wx.ColourDatabase.Find`  or find the names for the standard colour using :meth:`~wx.ColourDatabase.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 <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 :meth:`~wx.ColourDatabase.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: 



.. include:: rest_substitutions\tables\wx.ColourDatabase.1.rst



See the "Database colours" page of the :ref:`Drawing Sample <drawing sample>`  to see how all these colours look like. 








         



.. seealso:: :ref:`wx.Colour`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>ColourDatabase</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.ColourDatabase_inheritance.svg" alt="Inheritance diagram of ColourDatabase" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.ColourDatabase.html" title="wxWidgets maintains a database of standard ``RGB`` colours for a predefined set of named colours." alt="" coords="5,5,175,34"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.ColourDatabase.__init__`                                              Constructs the colour database.
:meth:`~wx.ColourDatabase.AddColour`                                             Adds a colour to the database.
:meth:`~wx.ColourDatabase.Find`                                                  Finds a colour given the name.
:meth:`~wx.ColourDatabase.FindColour`                                            
:meth:`~wx.ColourDatabase.FindName`                                              Finds a colour name given the colour.
:meth:`~wx.ColourDatabase.GetAllNames`                                           List all known colours by name.
:meth:`~wx.ColourDatabase.UseScheme`                                             Select the colour scheme to use.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.ColourDatabase.AllNames`                                              See :meth:`~wx.ColourDatabase.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.



   .. method:: __init__(self)

      Constructs the colour database. 
                 

      It will be initialized at the first use. 
                 

      :rtype: `None`     








   .. method:: AddColour(self, colourName, colour)

      Adds a colour to the database. 
                 

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


      :param `colourName`: 
      :type `colourName`: string
      :param `colour`: 
      :type `colour`: wx.Colour




      :rtype: `None`     








   .. method:: Find(self, colourName)

      Finds a colour given the name. 
                 

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


      :param `colourName`: 
      :type `colourName`: string




      :rtype: :ref:`wx.Colour`








   .. method:: FindColour(self, colour)




   .. method:: FindName(self, colour)

      Finds a colour name given the colour. 
                 

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


      :param `colour`: 
      :type `colour`: wx.Colour




      :rtype: `str`








   .. method:: GetAllNames(self)

      List all known colours by name. 
                 


                

      :rtype: `VectorwxString`     







      .. versionadded:: 4.3/wxWidgets-3.3.0  
     








   .. method:: UseScheme(self, scheme)

      Select the colour scheme to use. 
                 

      By default, :ref:`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 <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  :meth:`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. 


                


      :param `scheme`: 
      :type `scheme`: wx.ColourDatabase.Scheme




      :rtype: `None`     







      .. versionadded:: 4.3/wxWidgets-3.3.0  
     








   .. attribute:: AllNames

      See :meth:`~wx.ColourDatabase.GetAllNames`


.. toctree::
   :maxdepth: 1
   :hidden:

   wx.ColourDatabase.Scheme.enumeration
