This class includes all the widgets down the center third of the application:
ColorReadout widget shows the text and
background colors in
#RRGGBB form, and has a
pair of radiobuttons for selecting whether the rest of this
widget displays the text (foreground) color or the background
ModelSelector widget has radiobuttons that
let the user select HSV, RGB, or CMY color space.
ColorSliders widget has three Tkinter
Scale widgets the user can slide in order to make
fine adjustments to a color.
Adjuster widget class, then, is really the
central “brain” of the application. Inside this
object are stored the current background and text colors.
Here is the class interface. As with all compound widgets, it
inherits its widgetness from the
# - - - - - c l a s s A d j u s t e r class Adjuster(Frame): """Widgets to store and adjust the current colors. Exports: Adjuster ( parent, callback=None ): [ (parent is a Frame) and (callback is a function or None) -> parent := parent with a new Adjuster widget added but not gridded, which will call callback whenever the displayed color is changed, where the calling sequence is callback(isText, newColor) and isText is True to set the text color, False to set the background color, and newColor is a the new color as a Color instance return that new Adjuster widget ]
The next two methods return the current colors; see
Section 15.3, “
Adjuster.textColor(): Return the
current text color” and
Section 15.4, “
Adjuster.bgColor(): Return the
current text color”.
.textColor(): [ return the current text color as a Color instance ] .bgColor(): [ return the current background color as a Color instance ]
.set() method changes the currently
displayed color; see Section 15.2, “
Adjuster.set(): Change the color”.
.set ( color ): [ color is a Color instance -> if self is displaying the text color -> self's text color := color else -> self's background color := color ]
.isText() method tests whether the
sliders are displaying the text color or the background
color; see Section 15.5, “
Adjuster.isText(): Which color is being
.isText(): [ if self is displaying the text color -> return True else -> return False ]
One might ask, instead of making
method call, why not make it simply an exported read-only
Boolean? It is made a method strictly for the
convenience of the implementer: this way, the actual value can
be kept in the same Tkinter
variable that is linked to the two radiobuttons that control
Here is the layout of the widgets inside.
Contained widgets: .__colorReadout: [ a ColorReadout widget that displays self's text and background colors, and a pair of radiobuttons to switch between them ] .__modelSelector: [ a ModelSelector widget that lets the user select which color model to display ] .__colorSliders: [ a ColorSliders widget that lets the user adjust the color model's parameters ] Grid plan: Vertically stacked in a single column. """