There are four methods that deal with color: colormapfull, rgb, cells, and depth. They are described in the following sections.
$isfull = $widget->colormapfull;
The colormapfull method returns a 1 if the colormap is full and 0 if it is not full.
$count = $widget->cells;
The value returned is a number indicating the number of colors; for example, 64.
$depth = $widget->depth; # $depth might contain "16"
You can translate a color name to the red, green, and blue values by using the rgb method. Send rgb a color name and it returns a list containing three items that represent the red, green, and blue numbers.
($red, $green, $blue) = $widget->rgb("color");
Now $red, $green,and $blue each contain an integer from to 2n-1, where n is the number of bit planes in your display. For 8-bit color, the maximum value is 255 (0xFF); for 16-bit color, it's 65,535 (0xFFFF).
When specifying a hexadecimal color, feel free to over-specify the value. For instance, if you want the color red, use 0xFFFF00000000. Tk will use it if possible, or will down-convert it to 0xFF0000 for an 8-bit display.
The background color of $widget is set to the specified color, and the colors for all other widgets are calculated based on that color. So if a Button's edge is a lighter color than the background, it will show up a lighter shade of whatever color you pick. This method affects the entire application even if you only call it on a widget instead of a Toplevel.
You can set colors for explicit options by specifying the name and then the color to associate with it. For instance, the following code will set all foreground items in the application to red and all background items to blue:
$b->setPalette(background => "blue", foreground => "red");
The bisque method sets the entire application to use a bisque scheme, the original Tcl color. Calling $widget->bisque is the same as calling $widget->setPalette("bisque"). This is the only predefined color scheme, mainly for Tcl old-timers who remember the days before the new steel scheme was voted in.