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

==========================================================================================================================================
|phoenix_title|  **wx.ColourDialog**
==========================================================================================================================================

This class represents the colour chooser dialog.          

Starting from wxWidgets 3.1.3 and currently in the MSW port only, this dialog generates wxEVT_COLOUR_CHANGED events while it is being shown, i.e. from inside its :meth:`~wx.ColourDialog.ShowModal`  method, that notify the program about the change of the currently selected colour and allow it to e.g. preview the effect of selecting this colour. Note that if you react to this event, you should also correctly revert to the previously selected colour if the dialog is cancelled by the user. 

Example of using this class with dynamic feedback for the selected colour: ::

    # Some function for redrawing using the given colour. Ideally, it
    # shouldn't do anything if the colour is the same as the one used
    # before.
    def Redraw(self, colour):
        ...

    def OnColourChanged(self, event):
        self.Redraw(event.GetColour())

    def SelectNewColour(self):
        data = wx.ColourData()
        data.SetColour(initialColourToUse)
        dlg = wx.ColourDialog(self, data)
        dlg.Bind(wx.EVT_COLOUR_CHANGED, self.OnColourChanged)
        if (dlg.ShowModal() == wx.ID_OK)
            # Colour did change.
        else
            # Colour didn't change.

        # This call is unnecessary under platforms generating
        # wx.EVT_COLOUR_CHANGED if the dialog was accepted and unnecessary
        # under the platforms not generating this event if it was cancelled,
        # so we could check for the different cases explicitly to avoid it,
        # but it's simpler to just always call it.
        Redraw(data.GetColour())









         



.. seealso:: :ref:`ColourDialog Overview <colourdialog overview>`, :ref:`wx.Colour`, :ref:`wx.ColourData`, :ref:`wx.ColourDialogEvent`, :ref:`wx.GetColourFromUser`    







|

|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>ColourDialog</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.ColourDialog_inheritance.png" alt="Inheritance diagram of ColourDialog" 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.ColourDialog.html" title="wx.ColourDialog" alt="" coords="44,469,173,499"/> <area shape="rect" id="node2" href="wx.Dialog.html" title="wx.Dialog" alt="" coords="65,392,152,421"/> <area shape="rect" id="node3" href="wx.TopLevelWindow.html" title="wx.TopLevelWindow" alt="" coords="31,315,186,344"/> <area shape="rect" id="node4" href="wx.NonOwnedWindow.html" title="wx.NonOwnedWindow" alt="" coords="25,237,193,267"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="60,160,157,189"/> <area shape="rect" id="node6" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node7" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node8" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


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

================================================================================ ================================================================================
:meth:`~wx.ColourDialog.__init__`                                                Constructor.
:meth:`~wx.ColourDialog.Create`                                                  Same as :ref:`wx.ColourDialog`.
:meth:`~wx.ColourDialog.GetClassDefaultAttributes`                               
:meth:`~wx.ColourDialog.GetColourData`                                           Returns the colour data associated with the colour dialog.
:meth:`~wx.ColourDialog.ShowModal`                                               Shows the dialog, returning ``wx.ID_OK`` if the user pressed ``wx.OK``, and ``wx.ID_CANCEL`` otherwise.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.ColourDialog.ColourData`                                              See :meth:`~wx.ColourDialog.GetColourData`
================================================================================ ================================================================================


|


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


.. class:: wx.ColourDialog(Dialog)

   **Possible constructors**::

       ColourDialog(parent, data=None)
       
   
   This class represents the colour chooser dialog.



   .. method:: __init__(self, parent, data=None)

      Constructor.                  

      Pass a parent window, and optionally a pointer to a block of colour data, which will be copied to the colour dialog's colour data. 

      Custom colours from colour data object will be used in the dialog's colour palette. Invalid entries in custom colours list will be ignored on some platforms(GTK) or replaced with white colour on platforms where custom colours palette has fixed size (MSW). 

                


      :param `parent`: 
      :type `parent`: wx.Window
      :param `data`: 
      :type `data`: wx.ColourData






      .. seealso:: :ref:`wx.ColourData`    








   .. method:: Create(self, parent, data=None)

      Same as :ref:`wx.ColourDialog`.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `data`: 
      :type `data`: wx.ColourData




      :rtype: `bool`








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




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




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetColourData(self)

      Returns the colour data associated with the colour dialog.                  

      :rtype: :ref:`wx.ColourData`








   .. method:: ShowModal(self)

      Shows the dialog, returning ``wx.ID_OK`` if the user pressed ``wx.OK``, and ``wx.ID_CANCEL`` otherwise.                  

      :rtype: `int`








   .. attribute:: ColourData

      See :meth:`~wx.ColourDialog.GetColourData`

