.. 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.ColourPickerCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.ColourPickerCtrl**
==========================================================================================================================================

This control allows the user to select a colour.          

The generic implementation is a button which brings up a :ref:`wx.ColourDialog`  when clicked. Native implementation may differ but this is usually a (small) widget which give access to the colour-chooser dialog. It is only available if  ``USE_COLOURPICKERCTRL``   is set to 1 (the default). 





.. _ColourPickerCtrl-styles:

|styles| Window Styles
================================

This class supports the following styles: 

  

- ``wx.CLRP_DEFAULT_STYLE``: The default style: 0.  
- ``wx.CLRP_USE_TEXTCTRL``: Creates a text control to the left of the picker button which is completely managed by the :ref:`wx.ColourPickerCtrl`  and which can be used by the user to specify a colour (see SetColour). The text control is automatically synchronized with button's value. Use functions defined in :ref:`wx.PickerBase`  to modify the text control.  
- ``wx.CLRP_SHOW_LABEL``: Shows the colour in HTML form (``AABBCC``) as colour button label (instead of no label at all).  
- ``wx.CLRP_SHOW_ALPHA``: Allows selecting opacity in the colour-chooser (effective under wxGTK and wxOSX).  








.. _ColourPickerCtrl-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive a :ref:`wx.ColourPickerEvent` parameter.


- EVT_COLOURPICKER_CHANGED: The user changed the colour selected in the control either using the button or using text control (see  ``CLRP_USE_TEXTCTRL`` ; note that in this case the event is fired only if the user’s input is valid, i.e. recognizable). When using a popup dialog for changing the colour, this event is sent only when the changes in the dialog are accepted by the user, unlike   ``EVT_COLOURPICKER_CURRENT_CHANGED`` .   
- EVT_COLOURPICKER_CURRENT_CHANGED: The user changed the currently selected colour in the dialog associated with the control. This event is sent immediately when the selection changes and you must also handle  ``EVT_COLOUR_CANCELLED``   to revert to the previously selected colour if the selection ends up not being accepted. This event is new since wxWidgets 3.1.3 and currently is only implemented in wxMSW.   
- EVT_COLOURPICKER_DIALOG_CANCELLED: The user cancelled the colour dialog associated with the control, i.e. closed it without accepting the selection. This event is new since wxWidgets 3.1.3 and currently is only implemented in wxMSW.  








         



.. seealso:: :ref:`wx.ColourDialog`, :ref:`wx.ColourPickerEvent`    







|

|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>ColourPickerCtrl</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.ColourPickerCtrl_inheritance.png" alt="Inheritance diagram of ColourPickerCtrl" 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.ColourPickerCtrl.html" title="wx.ColourPickerCtrl" alt="" coords="33,392,184,421"/> <area shape="rect" id="node2" href="wx.PickerBase.html" title="wx.PickerBase" alt="" coords="50,315,167,344"/> <area shape="rect" id="node3" href="wx.Control.html" title="wx.Control" alt="" coords="63,237,155,267"/> <area shape="rect" id="node4" href="wx.Window.html" title="wx.Window" alt="" coords="60,160,157,189"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node6" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


|appearance| Control Appearance
===============================

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.colourpickerctrl.png
   :alt: wxMSW
   :figclass: floatleft

   **wxMSW**


.. figure:: _static/images/widgets/fullsize/wxmac/wx.colourpickerctrl.png
   :alt: wxMAC
   :figclass: floatright

   **wxMAC**


.. figure:: _static/images/widgets/fullsize/wxgtk/wx.colourpickerctrl.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|


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

================================================================================ ================================================================================
:meth:`~wx.ColourPickerCtrl.__init__`                                            
:meth:`~wx.ColourPickerCtrl.Create`                                              Creates a colour picker with the given arguments.
:meth:`~wx.ColourPickerCtrl.GetClassDefaultAttributes`                           
:meth:`~wx.ColourPickerCtrl.GetColour`                                           Returns the currently selected colour.
:meth:`~wx.ColourPickerCtrl.SetColour`                                           Sets the currently selected colour.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.ColourPickerCtrl.Colour`                                              See :meth:`~wx.ColourPickerCtrl.GetColour` and :meth:`~wx.ColourPickerCtrl.SetColour`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.ColourPickerCtrl(PickerBase)

   **Possible constructors**::

       ColourPickerCtrl()
       
       ColourPickerCtrl(parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition,
                        size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator,
                        name=ColourPickerCtrlNameStr)
       
   
   This control allows the user to select a colour.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition, size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator, name=ColourPickerCtrlNameStr)`
      
      Initializes the object and calls :meth:`Create`   with all the parameters.                  
      
      
      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `colour`: 
      :type `colour`: wx.Colour
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      :param `validator`: 
      :type `validator`: wx.Validator
      :param `name`: 
      :type `name`: string
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Create(self, parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition, size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator, name=ColourPickerCtrlNameStr)

      Creates a colour picker with the given arguments.                  




      :param `parent`: Parent window, must not be non-NULL.   
      :type `parent`: wx.Window
      :param `id`: The identifier for the control.   
      :type `id`: wx.WindowID
      :param `colour`: The initial colour shown in the control.   
      :type `colour`: wx.Colour
      :param `pos`: Initial position.   
      :type `pos`: wx.Point
      :param `size`: Initial size.   
      :type `size`: wx.Size
      :param `style`: The window style, see ``CRLP_`` flags.   
      :type `style`: long
      :param `validator`: Validator which can be used for additional date checks.   
      :type `validator`: wx.Validator
      :param `name`: Control name.  
      :type `name`: string




















      :rtype: `bool`



                  



      :returns: 

         ``True`` if the control was successfully created or ``False`` if creation failed.   








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetColour(self)

      Returns the currently selected colour.                  

      :rtype: :ref:`wx.Colour`








   .. method:: SetColour(self, *args, **kw)

      Sets the currently selected colour.                  

      See :meth:`wx.Colour.Set` .                   


      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetColour** `(self, col)`
      
      
      
      
      :param `col`: 
      :type `col`: wx.Colour
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetColour** `(self, colname)`
      
      
      
      
      :param `colname`: 
      :type `colname`: string
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. attribute:: Colour

      See :meth:`~wx.ColourPickerCtrl.GetColour` and :meth:`~wx.ColourPickerCtrl.SetColour`

