www.gibmonks.com

  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 37.  Tk Widget Attributes


Borders and Relief

Example 37-2 illustrates the different reliefs:

Example 37-2 3D relief sampler.

graphics/37fig02.gif


frame .f -borderwidth 10
pack .f
foreach relief {raised sunken flat ridge groove solid} {
   label .f.$relief -text $relief -relief $relief \
      -bd 2 -padx 3
   pack .f.$relief -side left -padx 4
}

The three-dimensional appearance of widgets is determined by two attributes: borderWidth and relief. The borderWidth adds extra space around the edge of a widget's display, and this area can be displayed in a number of ways according to the relief attribute. The solid relief was added in Tk 8.0 to support the Macintosh look for entry widget, and it works well against white backgrounds. Macintosh and Windows buttons do not support different reliefs, and the Macintosh buttons do not honor border width.

The activeBorderWidth attribute is a special case for menus. It defines the border width for the menu entries. The relief of a menu is not configurable. It probably is not worth adjusting the menu border width attributes because the default looks OK. The native menus on Windows and Macintosh do not honor this attribute.

The activeRelief applies to the elements of a scrollbar (the elevator and two arrows) when the mouse is over them. The elementBorderWidth sets the size of the relief on these elements. Changing the activeRelief does not look good. The native scrollbars on Macintosh and Windows do not honor this attribute. Table 37-2 lists the attributes for borders and relief.

Table 37-2. Border and relief attribute resource names.
borderWidth

The width of the border around a widget, in screen units.

Widgets: button, canvas, checkbutton, entry, frame, label, listbox, menu, menubutton, message, radiobutton, scale, scrollbar, text, and toplevel.

bdShort for borderwidth. Tcl commands only.
elementBorderWidthThe width of the border on scrollbar and scale elements.
relief

The appearance of the border.

Values: flat, raised, sunken, ridge, groove, or solid.

Widgets: button, canvas, checkbutton, entry, frame, label, listbox, menubutton, message, radiobutton, scale, scrollbar, text, and toplevel.

activeBorderWidthThe border width for menu entries. UNIX only.
activeReliefThe relief for active scrollbar elements. UNIX only.


      Previous section   Next section
    Top