Node:label, Next:, Up:Widget Creation


A label is a simple widget for displaying a single line of text. An example of creating an instance of a label is

label .l -text "Hello world!"

which simply creates the label named .l with the text Hello world! displayed in it. Most widgets that display text can have a variable associated with them through the option -textvariable. When the value of the variable is changed the text changes in the associated label. For example,

label .l -text "Hello world!" -textvariable mytext

creates a text label called .l displaying the initial text Hello world! and associated text variable mytext; mytext will start with the value Hello world!. However, if the following script is executed:

set mytext "Goodbye moon!"

then magically the text in the label will change to Goodbye moon!.