Pmw.Color - contains functions for handling colors and color schemes
This module is a set of functions for manipulating colors and for modifying the color scheme of an application or a widget. Many of the functions in this module take or return colors. These values may represent colors in the following ways:
[1.0, 0.6, 0.0].
As used in these functions, the brightness of a color is the perceived grey level of the color as registered by the human eye. For example, even though the colors red, blue and yellow have the same intensity (1.0), they have different brightnesses, 0.299, 0.114 and 0.886 respectively, reflecting the different way these colors appear to the eye. The brightness of a color is a value between 0.0 (dark) and 1.0 (bright).
A color scheme is a set of colors defined for each of the
default color options in the Tk option database. Color schemes
can be used in two ways. Firstly, using
the Tk option database can be set to the values in the color
scheme. This will not have any effect on currently existing
widgets, but any new widgets created after setting the options
will have these colors as their defaults. Secondly, using
Pmw.Color.changecolor() the color scheme can be used to change
the colors of a widget and all its child widgets.
A color scheme is specified by defining one or more color options
(one of the defined options must be
background). Not all
options need be specified - if any options are not defined, they
are calculated from the other colors. These are the options used
by a color scheme, together with their values if not specified:
background: (must be specified) foreground: black activeForeground: same as foreground insertBackground: same as foreground selectForeground: same as foreground highlightColor: same as foreground disabledForeground: between fg and bg but closer to bg highlightBackground: same as background activeBackground: a little lighter that bg selectBackground: a little darker that bg troughColor: a little darker that bg selectColor: yellow
There are many functions in this module. As well as
Pmw.Color.changecolor(), some of the
most useful are
(light, dark)of color names that can be used as the light and dark border shadows on a widget where the background is colorName. This is the same method that Tk uses for shadows when drawing reliefs on widget borders. The root argument is only used to query Tk for the rgb values of colorName.
For example to change a widget to have a red color scheme with a white foreground:
Pmw.Color.changecolor(widget, background = 'red3', foreground = 'white')
The colors of widgets created after this call will not be affected.
Note that widget must be a Tk widget or toplevel. To change the color of a Pmw megawidget, use it's hull component. For example:
widget = megawidget.component('hull') Pmw.Color.changecolor(widget, background = 'red3')
To do this, a few widgets are created as children of root, their defaults are queried, and then the widgets are destroyed. (Tk supplies no other way to get widget default values.)
Note that root must be a Tk widget or toplevel. To use a Pmw megawidget as the root, use it's hull component. For example:
root = megawidget.component('hull') Pmw.Color.getdefaultpalette(root)
'#RRGGBB'suitable for use with Tk color functions.
For example to initialise an application to have a red color scheme with a white foreground:
Pmw.Color.setscheme(root, background = 'red3', foreground = 'white')
This function does not modify the colors of already existing widgets. Use Pmw.Color.changecolor() to do this.
Note that root must be a Tk widget or toplevel. To use the Tk option database of the root window of a Pmw megawidget, use the megawidget's hull component. For example:
root = megawidget.component('hull') Pmw.Color.setscheme(root, background = 'red3')
If returnHues is false, the return values are the names of the colors represented by the hues together with saturation and intensity and corrected by correction.
If returnHues is true, the return values are hues.
Pmw 1.3 -
6 Aug 2007
Manual page last reviewed: 25 May 2002