| Previous | Next
Color-Related MethodsThere are four methods that deal with color: Is the Colormap Full?To determine if the colormap for the widget is full, use $isfull = $widget->colormapfull; The Cell CountThe number of cells in the colormap can be obtained by using the $count = $widget->cells; The value returned is a number indicating the number of colors; for example, 64. Color DepthYou can get the number of bits per pixel by using the $depth = $widget->depth; # $depth might contain "16" Translate to RGB ValueYou can translate a color name to the red, green, and blue values by using the
Now 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. Setting ColorsYou can have your entire application based on one color automatically by using the $widget->setPalette( The background color of 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"); Note that this is the only widget we know of where you cannot use a leading dash for an option. Predefined Color SchemeThe |