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

.. currentmodule:: wx.lib.colourchooser.pycolourchooser

.. highlight:: python



.. _wx.lib.colourchooser.pycolourchooser.PyColourChooser:

==========================================================================================================================================
|phoenix_title|  **wx.lib.colourchooser.pycolourchooser.PyColourChooser**
==========================================================================================================================================

A Pure-Python implementation of the colour chooser dialog.

The PyColourChooser is a pure python implementation of the colour
chooser dialog. It's useful for embedding the colour choosing functionality
inside other widgets, when the pop-up dialog is undesirable. It can also
be used as a drop-in replacement on the GTK platform, as the native
dialog is kind of ugly.



|

|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>PyColourChooser</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.lib.colourchooser.pycolourchooser.PyColourChooser_inheritance.png" alt="Inheritance diagram of PyColourChooser" 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.lib.colourchooser.pycolourchooser.PyColourChooser.html" title="wx.lib.colourchooser.pycolourchooser.PyColourChooser" alt="" coords="5,392,385,421"/> <area shape="rect" id="node2" href="wx.Panel.html" title="wx.Panel" alt="" coords="155,315,235,344"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window" alt="" coords="147,237,244,267"/> <area shape="rect" id="node4" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="131,160,260,189"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="137,83,254,112"/> <area shape="rect" id="node6" href="wx.Object.html" title="wx.Object" alt="" coords="92,5,179,35"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="203,5,310,35"/> </map> 
   </p>
   </div>

|


|super_classes| Known Superclasses
==================================

:class:`wx.Panel`

|


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

=================================================================================== ================================================================================
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.__init__`              Creates an instance of the colour chooser. Note that it is best to
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.colourToHSV`           Convert wx.Colour to hsv triplet
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.doPaletteClick`        Updates the colour values based on the mouse location
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.getColourFromControls` Calculate current colour from HS box position and V slider.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.GetValue`              Returns a wxColour object indicating the current colour choice.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.getValueAsFloat`       If you type garbage, you get, literally, nothing (0)
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.getVFromSlider`        Get the current value of "V" from the v slider.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.hsvToColour`           Convert hsv triplet to wx.Colour
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.InitColours`           Initializes the pre-set palette colours.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onAddCustom`           Adds a custom colour to the custom colour box set. Boxes are
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onBasicClick`          Highlights the selected colour box and updates the solid colour
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onColourSliderClick`   Shared helper for onSliderDown()/onSliderMotion()
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onCustomClick`         Highlights the selected custom colour box and updates the solid
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onHSVKillFocus`        
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onPaletteCaptureLost`  
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onPaletteDown`         Stores state that the mouse has been pressed and updates
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onPaletteMotion`       Updates the colour values during mouse motion while the
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onPaletteUp`           Stores state that the mouse is no longer depressed.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onRGBKillFocus`        
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onScroll`              Updates the display to reflect the new "Value".
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onSliderDown`          Handle mouse click on the colour slider palette
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onSliderMotion`        Handle mouse-down drag on the colour slider palette
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.onSliderUp`            
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.setCustomColour`       Sets the custom colour at the given index. true_colour is wxColour
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.setSliderToV`          Set a new HSV value for the v slider. Does not update displayed colour.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.SetValue`              Updates the colour chooser to reflect the given wxColour.
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.UpdateColour`          Updates displayed colour and HSV controls with the new colour
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.updateDisplayColour`   Update the displayed color box (solid) and send the EVT_COLOUR_CHANGED
:meth:`~wx.lib.colourchooser.pycolourchooser.PyColourChooser.UpdateEntries`         Updates the color levels to display the new values.
=================================================================================== ================================================================================


|


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


.. class:: PyColourChooser(wx.Panel)

   A Pure-Python implementation of the colour chooser dialog.
   
   The PyColourChooser is a pure python implementation of the colour
   chooser dialog. It's useful for embedding the colour choosing functionality
   inside other widgets, when the pop-up dialog is undesirable. It can also
   be used as a drop-in replacement on the GTK platform, as the native
   dialog is kind of ugly.

   .. method:: __init__(self, parent, id)

      Creates an instance of the colour chooser. Note that it is best to
      accept the given size of the colour chooser as it is currently not
      resizeable.


   .. method:: colourToHSV(self, colour)

      Convert wx.Colour to hsv triplet


   .. method:: doPaletteClick(self, m_x, m_y)

      Updates the colour values based on the mouse location
      over the palette.


   .. method:: getColourFromControls(self)

      Calculate current colour from HS box position and V slider.
      return - wx.Colour


   .. method:: GetValue(self)

      Returns a wxColour object indicating the current colour choice.


   .. method:: getValueAsFloat(self, textctrl)

      If you type garbage, you get, literally, nothing (0)


   .. method:: getVFromSlider(self)

      Get the current value of "V" from the v slider.


   .. method:: hsvToColour(self, hsv)

      Convert hsv triplet to wx.Colour


   .. method:: InitColours(self)

      Initializes the pre-set palette colours.


   .. method:: onAddCustom(self, event)

      Adds a custom colour to the custom colour box set. Boxes are
      chosen in a round-robin fashion, eventually overwriting previously
      added colours.


   .. method:: onBasicClick(self, event, box)

      Highlights the selected colour box and updates the solid colour
      display and colour slider to reflect the choice.


   .. method:: onColourSliderClick(self, y)

      Shared helper for onSliderDown()/onSliderMotion()


   .. method:: onCustomClick(self, event, box)

      Highlights the selected custom colour box and updates the solid
      colour display and colour slider to reflect the choice.


   .. method:: onHSVKillFocus(self, event)


   .. method:: onPaletteCaptureLost(self, event)


   .. method:: onPaletteDown(self, event)

      Stores state that the mouse has been pressed and updates
      the selected colour values.


   .. method:: onPaletteMotion(self, event)

      Updates the colour values during mouse motion while the
      mouse button is depressed.


   .. method:: onPaletteUp(self, event)

      Stores state that the mouse is no longer depressed.


   .. method:: onRGBKillFocus(self, event)


   .. method:: onScroll(self, event)

      Updates the display to reflect the new "Value".


   .. method:: onSliderDown(self, event)

      Handle mouse click on the colour slider palette


   .. method:: onSliderMotion(self, event)

      Handle mouse-down drag on the colour slider palette


   .. method:: onSliderUp(self, event)


   .. method:: setCustomColour (self, index, true_colour, base_colour, slidepos)

      Sets the custom colour at the given index. true_colour is wxColour
      object containing the actual rgb value of the custom colour.
      base_colour (wxColour) and slidepos (int) are used to configure the
      colour slider and set everything to its original position.


   .. method:: setSliderToV(self, v)

      Set a new HSV value for the v slider. Does not update displayed colour.


   .. method:: SetValue(self, colour)

      Updates the colour chooser to reflect the given wxColour.


   .. method:: UpdateColour(self, colour)

      Updates displayed colour and HSV controls with the new colour


   .. method:: updateDisplayColour(self, colour)

      Update the displayed color box (solid) and send the EVT_COLOUR_CHANGED


   .. method:: UpdateEntries(self, colour)

      Updates the color levels to display the new values.


