This class is a compound widget containing only two internal widgets.
On top is a large Text widget that displays
some text in the currently selected font using the currently
selected foreground color, and its background color is the
currently selected background color.
Below that is a FontSelect widget that
allows the user to select different text fonts. For a
link to this compound widget's documentation, see Section 4.1, “Imports”.
Here is the class interface.
# - - - - - c l a s s S w a t c h
class Swatch(Frame):
"""Compound widget for text/background display and font selection.
Exports:
Swatch ( parent, bg, fg ):
[ (parent is a Frame) and
(bg is the initial background color as a Color instance) and
(fg is the initial foreground color as a Color instance) ->
parent := parent with a new Swatch widget added but not
gridded
return that new Swatch widget ]
These methods set either the foreground or background
color; see Section 20.2, “Swatch.setTextColor()” and
Section 20.3, “Swatch.setBgColor()”.
.setTextColor ( color ):
[ color is a color as a Color instance ->
self := self with the text displayed in that color ]
.setBgColor ( color ):
[ color is a color as a Color instance ->
self := self with the background set to color ]
Internal widgets:
.__text: [ a Text widget ]
.__fontSelect: [ a FontSelect widget ]
Grid plan: One vertical column.
The internal state includes the current foreground and background colors, and also the current font.
State/Invariants:
.__textColor: [ current text color as a Color ]
.__bgColor: [ current background color as a Color ]
.__font: [ current font as a tkFont.Font ]
"""