[ Team LiB ] Previous Section Next Section

Text Attributes

Layout

Table 42-4 summarizes two simple text layout attributes: justify and wrapLength. The text widget has several more layout-related attributes, and Chapter 36 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 30, 32, and 34. 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 42-4. Layout attribute resource names

justify

Text line justification. Values: left, center, or right.

Widgets: button, checkbutton, entry, label, menubutton, message, and radiobutton.

wrapLength

Maximum line length for text, in screen units. Widgets: button, checkbutton, label, menubutton, and radiobutton.

Selection Attributes

Table 42-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 42-5. Selection attribute resource names

exportSelection

Share selection. Widgets: entry, canvas, listbox, and text.

selectForeground

Foreground of selected text.

selectBackground

Background of selected text.

selectBorderWidth

Width of 3D raised border for selection highlight.

    [ Team LiB ] Previous Section Next Section