The widget roundup provides you with a quick and easy reference to the most important features
and options for each Tk widget.
Label
Widget Essentials
When to use: | To show a static text or image to the user, whether identifying some other user interface element (e.g. "Name" next to an entry), something purely decorative, or presenting a result. Users normally do not interact with labels. |
---|---|
Python: | lbl = ttk.Label(parent, text="Name:") |
Tcl: | ttk::label .lbl -text "Name:" |
Ruby: | lbl = Tk::Tile::Label.new(parent) {text "Name:"} |
Perl: | my $lbl = parent->new_ttk__label(-text => "Name:"); |
Reference: | (at www.tcl.tk) |
Common Options
text | The text string to be shown in the label. |
---|---|
textvariable | As an alternative to text, get the string from a variable, updating when the variable changes. |
image, compound |
Specify a Tk Image object (not the path to an image file) instead of the text string. If compound is center, top, bottom, left, or right, display the text and the image. |
justify | Alignment of text: left, center or right. |
wraplength | For multi-line labels; let Tk calculate the line breaks rather than explicitly embedding newlines in the text string. |