Table Of Contents

Previous topic

pycolourchooser

Next topic

pycolourslider

This Page

phoenix_title 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 Inheritance Diagram

Inheritance diagram for class PyColourChooser

Inheritance diagram of PyColourChooser


super_classes Known Superclasses

Panel


method_summary Methods Summary

__init__ Creates an instance of the colour chooser. Note that it is best to
doPaletteClick Updates the colour values based on the mouse location
GetValue Returns a wxColour object indicating the current colour choice.
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
onCustomClick Highlights the selected custom colour box and updates the solid
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.
onScroll Updates the solid colour display to reflect the changing slider.
setCustomColour Sets the custom colour at the given index. true_colour is wxColour
SetValue Updates the colour chooser to reflect the given wxColour.
UpdateColour Performs necessary updates for when the colour selection has
UpdateEntries Updates the color levels to display the new values.

api Class API



class PyColourChooser(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.



doPaletteClick(self, m_x, m_y)

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



GetValue(self)

Returns a wxColour object indicating the current colour choice.



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.



onCustomClick(self, event, box)

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



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.



onScroll(self, event)

Updates the solid colour display to reflect the changing slider.



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.



SetValue(self, colour)

Updates the colour chooser to reflect the given wxColour.



UpdateColour(self, colour)

Performs necessary updates for when the colour selection has changed.



UpdateEntries(self, colour)

Updates the color levels to display the new values.