Next | Prev | Up | Top | Contents | Index

xmLabel

A label widget simply contains some text. For example, this is the classic "Hello world" program in Tcl Motif:

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmLabel .lbl managed -labelString "Hello world!"
. realizeWidget
. mainLoop
Note that text is broken into separate lines only if you put newline symbols in it. Text may contains non-ASCII characters, using the encoding defined in the current font, usually ISO 8859-1.

This example shows more complex use of label widgets:

#! /usr/sgitcl/bin/moat 
xtAppInitialize
xmLabel .lbl managed
.lbl setValues -labelString {
    If your text contains newline symbols,\n
    it will be broken into separate lines.\n
    It may contain non-ASCII characters (àçéñôßü)
}
.lbl setValues \
    -stringDirection string_direction_r_to_l \
    -alignment alignment_end \
    -fontList -*courier-bold-r-*--18-* \
    -marginLeft 10 -marginWidth 10 \
    -x 200 -y 100
. realizeWidget
. mainLoop
Table 4-18 shows the resources for xmLabel.

xmLabel Resources
Resource NameDefault ValueType or Legal Value
-accelerator""String
-acceleratorText""String
-alignmentcenteralignment_center
alignment_beginning
alignment_end
-fontListinheritedfontList
-labelInsensitivePixmapnonePixmap
-labelPixmapnonePixmap
-labelStringwidget name String
-labelTypestring string//pixmap
-marginBottom0Integer
-marginHeight0Integer
-marginLeft0Integer
-marginRight0Integer
-marginTop0Integer
-marginWidth0Integer
-mnemonic""String
-mnemonicCharSetdynamicString
-recomputeSizeTrue Boolean
-stringDirection l_to_rstring_direction_l_to_r
string_direction_r_to_l

Some resources are used only in derived classes. When displayed text material changes, the size of the label may or may not be recomputed, depending on -recomputeSize. The label may display the -labelString or -labelPixmap resource, depending on the -labelType value. Labels are always centered top and bottom (inside their margins), but may be centered or left or right justified, depending on -alignment.

When a label is inactive (insensitive), the displayed text is grayed using a 50% pattern. You can change this pattern by specifying a pixmap with -label-Insensitive-Pixmap.

Table 4-19 lists resources inherited from the Primitive and Core classes.

xmLabel Inherited Resources
Resource InheritedFrom Resource InheritedFrom
-background (Core) -backgroundPixmap (Core)
-borderColor(Core) -borderWidth(Core)
-bottomShadowColor(Primitive) -bottomShadowPixmap(Primitive)
-foreground(Primitive) -height (Core)
-highlightColor(Primitive) -highlightOnEnter(Primitive)
-highlightPixmap(Primitive) -highlightThickness (Primitive)
-mappedWhenManaged(Core) -navigationType(Primitive)
-sensitive(Core) -shadowThickness(Primitive)
-topShadowColor(Primitive) -topShadowPixmap(Primitive)
-translations(Core) -traversalOn(Primitive)
-unitType(Primitive) -width(Core)
-x(Core) -y(Core)
-accelerators(Core)   

Labels do not define specific callbacks, but just inherit them from the Primitive class, namely helpCallback and destroyCallback.


Next | Prev | Up | Top | Contents | Index