www.gibmonks.com

  Previous section   Next section

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

Table of Contents
Chapter 39.  Fonts and Text Attributes


Text Attributes

Layout

Table 39-4 summarizes two simple text layout attributes: justify and wrapLength. The text widget has several more layout-related attributes, and Chapter 33 describes those in detail. The two attributes described in this section apply to the various button widgets, the label, entry, and message widgets. Those widgets are described in Chapters 27, 29, and 31. The justify attribute causes text to be centered, left-justified, or right-justified. The default justification is center for all the widgets in the table, except for the entry widget, which is left-justified by default.

The wrapLength attribute specifies how long a line of text is before it is wrapped onto another line. It is used to create multiline buttons and labels. This attribute is specified in screen units, however, not string length. It is probably easier to achieve the desired line breaks by inserting newlines into the text for the button or label and specifying a wrapLength of 0, which is the default.

Table 39-4. Layout attribute resource names
justifyText line justification. Values: left, center, or right. Widgets: button, checkbutton, entry, label, menubutton, message, and radiobutton.
wrapLengthMaximum line length for text, in screen units. Widgets: button, checkbutton, label, menubutton, and radiobutton.

Selection Attributes

Table 39-5 lists the selection-related attributes. The exportSelection attribute controls if the selection is exported for cut and paste to other widgets. The colors for selected text are set with selectForeground and selectBackground. The selection is drawn in a raised relief, and the selectBorderWidth attribute affects the 3D appearance. Choose a border width of zero to get a flat relief.

Table 39-5. Selection attribute resource names.
exportSelectionShare selection. Widgets: entry, canvas, listbox, and text.
selectForegroundForeground of selected text.
selectBackgroundBackground of selected text.
selectBorderWidthWidth of 3D raised border for selection highlight.


      Previous section   Next section
    Top