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 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())

See also

ColourDialog Overview, wx.Colour, wx.ColourData, wx.ColourDialogEvent, wx.GetColourFromUser


class_hierarchy Class Hierarchy

Inheritance diagram for class ColourDialog:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__

Constructor.

Create

Same as wx.ColourDialog.

GetClassDefaultAttributes

GetColourData

Returns the colour data associated with the colour dialog.

ShowModal

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


property_summary Properties Summary

ColourData

See GetColourData


api Class API

class wx.ColourDialog(Dialog)

Possible constructors:

ColourDialog(parent, data=None)

This class represents the colour chooser dialog.


Methods

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

Parameters:

See also

wx.ColourData



Create(self, parent, data=None)

Same as wx.ColourDialog.

Parameters:
Return type:

bool



static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)
Parameters:

variant (WindowVariant) –

Return type:

wx.VisualAttributes



GetColourData(self)

Returns the colour data associated with the colour dialog.

Return type:

wx.ColourData



ShowModal(self)

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

Return type:

int


Properties

ColourData

See GetColourData