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

Inheritance diagram for class PyColourChooser:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

wx.Panel


method_summary Methods Summary

__init__

Creates an instance of the colour chooser. Note that it is best to

colourToHSV

Convert wx.Colour to hsv triplet

doPaletteClick

Updates the colour values based on the mouse location

getColourFromControls

Calculate current colour from HS box position and V slider.

GetValue

Returns a wxColour object indicating the current colour choice.

getValueAsFloat

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

getVFromSlider

Get the current value of “V” from the v slider.

hsvToColour

Convert hsv triplet to wx.Colour

InitColours

Initializes the pre-set palette colours.

onAddCustom

Adds a custom colour to the custom colour box set. Boxes are

onBasicClick

Highlights the selected colour box and updates the solid colour

onColourSliderClick

Shared helper for onSliderDown()/onSliderMotion()

onCustomClick

Highlights the selected custom colour box and updates the solid

onHSVKillFocus

onPaletteCaptureLost

onPaletteDown

Stores state that the mouse has been pressed and updates

onPaletteMotion

Updates the colour values during mouse motion while the

onPaletteUp

Stores state that the mouse is no longer depressed.

onRGBKillFocus

onScroll

Updates the display to reflect the new “Value”.

onSliderDown

Handle mouse click on the colour slider palette

onSliderMotion

Handle mouse-down drag on the colour slider palette

onSliderUp

setCustomColour

Sets the custom colour at the given index. true_colour is wxColour

setSliderToV

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

SetValue

Updates the colour chooser to reflect the given wxColour.

UpdateColour

Updates displayed colour and HSV controls with the new colour

updateDisplayColour

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

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.


Methods

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



colourToHSV(self, colour)

Convert wx.Colour to hsv triplet



doPaletteClick(self, m_x, m_y)

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



getColourFromControls(self)

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



GetValue(self)

Returns a wxColour object indicating the current colour choice.



getValueAsFloat(self, textctrl)

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



getVFromSlider(self)

Get the current value of “V” from the v slider.



hsvToColour(self, hsv)

Convert hsv triplet to wx.Colour



InitColours(self)

Initializes the pre-set palette colours.



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.



onBasicClick(self, event, box)

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



onColourSliderClick(self, y)

Shared helper for onSliderDown()/onSliderMotion()



onCustomClick(self, event, box)

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



onHSVKillFocus(self, event)


onPaletteCaptureLost(self, event)


onPaletteDown(self, event)

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



onPaletteMotion(self, event)

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



onPaletteUp(self, event)

Stores state that the mouse is no longer depressed.



onRGBKillFocus(self, event)


onScroll(self, event)

Updates the display to reflect the new “Value”.



onSliderDown(self, event)

Handle mouse click on the colour slider palette



onSliderMotion(self, event)

Handle mouse-down drag on the colour slider palette



onSliderUp(self, event)


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.



setSliderToV(self, v)

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



SetValue(self, colour)

Updates the colour chooser to reflect the given wxColour.



UpdateColour(self, colour)

Updates displayed colour and HSV controls with the new colour



updateDisplayColour(self, colour)

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



UpdateEntries(self, colour)

Updates the color levels to display the new values.