4.12. Altering the Button's StyleBy default, a Button looks like it's raised slightly off the surface of the window. By using the -relief option, you can change the style of the Button edges: -relief => 'flat'|'groove'|'raised'|'ridge'|'sunken'|'solid' The default for a Button widget is 'raised' and for Checkbuttons and Radiobuttons it is 'flat'. Each value changes the look of the Button slightly, as you can see in Figure 4-20. Here is a list of the styles:
No matter which value is specified for the -relief option, when the Button is pressed with the mouse, its relief will change to 'sunken'. Figure 4-20. Different relief types for a ButtonThe Checkbutton and Radiobutton start with flat relief. Figure 4-21 and Figure 4-22 show these. Figure 4-21. Different relief types for a CheckbuttonFigure 4-22. Different relief types for a RadiobuttonIn addition to changing the type of edge drawn around a Button, you can change the thickness of the edge by using -borderwidth: -borderwidth => amount The default -borderwidth for a Button is 2 and for a Checkbutton and a Radiobutton is 0. The wider the -borderwidth, the more dramatic the effects of the -relief option become. Figure 4-23 shows what a -borderwidth of 10 does to each relief type for a Button. When changing the -borderwidth on a Checkbutton or Radiobutton, be careful you don't use too large a value, because the indicators do funny things at larger values. Take a look at Figures Figure 4-24 through Figure 4-27 for clarification. Hopefully seeing how silly these look here, you won't waste time wondering why your own indicators don't work. Figure 4-23. Different relief types for a Button with -borderwidth set to 10Figure 4-24. Checkbuttons with -borderwidth => 4Figure 4-25. Checkbuttons with -borderwidth => 10Figure 4-26. Radiobuttons with -borderwidth => 4Figure 4-27. Radiobuttons with -borderwidth => 10Note that using -borderwidth with values greater than 4 makes widgets look extremely odd. In each of the widget chapters, you'll find a screenshot showing what happens to the widget with a larger -borderwidth value for each of the possible -relief values. The best use of -borderwidth is making one widget stand out more than the others temporarily during development. (You can also use this trick with Frames to figure out where the Frame is. Normally they are invisible. See Chapter 11, " Frame, MainWindow,and Toplevel Widgets" for more on this.) Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|