This page last updated
13 December 1997

Yhek's Page of Tcl/Tk Labels

If this spot is not green you may want to download the latest Tcl Plugin.

Tcl/Tk labels can also be used for the purpose originally intended - to display a simple line of text in a box. The HTML TABLE tag can be used for this too. Here are roughly equivalent versions.

A simple table

In Tcl/Tk, fonts are specified using the -font option. The font option can be expressed as a list of attributes - font pitch and list of style attributes such as bold italic.

Text can be placed in a label and some "text" is graphic by nature, but this is a pretty poor solution to a problem of more general graphic display. Agian the HTML TABLE can be used in these cases. However if you have some text that you want to display in a pretty box, then here are some options.

A label can be nested inside other frames:

It can be surrounded by a frame of small frames:

Tcl has historically been executed in a windows environment where the outer size of the window could be managed after the fact by the Windows Manager. The user could then move it around on the screen. Consequently, Tcl has been designed to pack its widgets from the smallest out to the largest. It packs into the smallest frame which will contain the requested data. But this may not quite match the HTML space which must be allocated beforehand. A change for instance to a slightly larger font size or type will cause requests for slightly larger frames.

WARNING - Label widgets have -width and -height options just like frames BUT they refer to lines of text down and characters across, not pixels. Trying to specify a label to be a specific size is difficult. It is better to place a label inside a frame or the remainder of a frames available space and have it use up the rest of that space, than to try and fix its position absolutely. The code for the above example is an instructive illustration of this technique.

It is now time to go back to the main Tcl page.


1997 nzci@outnet.co.nz

This page hosted by GeoCities Get your own Free Home Page