| Previous | Next
Color OptionsThe options that can change the Button's colors are For either Win32 or Unix systems, you can run the widget demo included with the Tk module. If the perl/bin directory is in your path, you can simply type Valid values for the color string are available on your Unix system in a file called rgb.txt. This file is typically located in the X11 lib directory, for example, /usr/X11R6/lib/rgb.txt. You can also use the X application xcolors or showrgb. Check the manpages for each command to determine the best way to use it. Another place to look for valid color names (and this applies to Win32 as well) is in your Perl distribution directory. Look for the file xcolors.h. It is a text file that contains the RGB values and names for quite a few colors. On a Win32 machine, it might be in C:\Perl\lib\site\Tk\ptk. The color of the Button depends on the Button's state. When the Button has a state of The background is specified like this: -background => The default background color is light gray. Figure 4-32 shows the results of changing the second Exit Button's background to blue. Figure 4-32. Example of -background => 'blue'The foreground of the Button is the text (or bitmap). The foreground color is specified like this: -foreground =>
Figure 4-33. Example of -background => 'blue' and -foreground => 'white'When you use the Figure 4-34. 'error' bitmap with -foreground => 'white' and -background => 'black'The -activebackground => These colors are different because we want users to have some visual clues that they can press the Button. By having the colors change slightly when the mouse cursor is over the Button, users know that the Button can be pressed to do something. The default for The final color option, -disabledforeground => When the Button is in a disabled state, it will not respond when the mouse cursor is over it or if it is pressed. The default text color (or bitmap color) is Figure 4-35. -disabledforeground example |