1label(n) Tk Built-In Commands label(n)
2
3
4
5______________________________________________________________________________
6
8 label - Create and manipulate 'label' non-interactive text or image
9 widgets
10
12 label pathName ?options?
13
15 -activebackground -disabledforeground -padx
16 -activeforeground -font -pady
17 -anchor -foreground -relief
18 -background -highlightbackground -takefocus
19 -bitmap -highlightcolor -text
20 -borderwidth -highlightthickness -textvariable
21 -compound -image -underline
22 -cursor -justify -wraplength
23
24 See the options manual entry for details on the standard options.
25
27 Command-Line Name:-height
28 Database Name: height
29 Database Class: Height
30
31 Specifies a desired height for the label. If an image or bitmap
32 is being displayed in the label then the value is in screen
33 units (i.e. any of the forms acceptable to Tk_GetPixels); for
34 text it is in lines of text. If this option is not specified,
35 the label's desired height is computed from the size of the im‐
36 age or bitmap or text being displayed in it.
37
38 Command-Line Name:-state
39 Database Name: state
40 Database Class: State
41
42 Specifies one of three states for the label: normal, active, or
43 disabled. In normal state the button is displayed using the
44 -foreground and -background options. In active state the label
45 is displayed using the -activeforeground and -activebackground
46 options. In the disabled state the -disabledforeground and
47 -background options determine how the button is displayed.
48
49 Command-Line Name:-width
50 Database Name: width
51 Database Class: Width
52
53 Specifies a desired width for the label. If an image or bitmap
54 is being displayed in the label then the value is in screen
55 units (i.e. any of the forms acceptable to Tk_GetPixels); for
56 text it is in characters. If this option is not specified, the
57 label's desired width is computed from the size of the image or
58 bitmap or text being displayed in it.
59______________________________________________________________________________
60
62 The label command creates a new window (given by the pathName argument)
63 and makes it into a label widget. Additional options, described above,
64 may be specified on the command line or in the option database to con‐
65 figure aspects of the label such as its colors, font, text, and initial
66 relief. The label command returns its pathName argument. At the time
67 this command is invoked, there must not exist a window named pathName,
68 but pathName's parent must exist.
69
70 A label is a widget that displays a textual string, bitmap or image.
71 If text is displayed, it must all be in a single font, but it can oc‐
72 cupy multiple lines on the screen (if it contains newlines or if wrap‐
73 ping occurs because of the -wraplength option) and one of the charac‐
74 ters may optionally be underlined using the -underline option. The la‐
75 bel can be manipulated in a few simple ways, such as changing its re‐
76 lief or text, using the commands described below.
77
79 The label command creates a new Tcl command whose name is pathName.
80 This command may be used to invoke various operations on the widget.
81 It has the following general form:
82 pathName option ?arg arg ...?
83 Option and the args determine the exact behavior of the command. The
84 following commands are possible for label widgets:
85
86 pathName cget option
87 Returns the current value of the configuration option given by
88 option. Option may have any of the values accepted by the label
89 command.
90
91 pathName configure ?option? ?value option value ...?
92 Query or modify the configuration options of the widget. If no
93 option is specified, returns a list describing all of the avail‐
94 able options for pathName (see Tk_ConfigureInfo for information
95 on the format of this list). If option is specified with no
96 value, then the command returns a list describing the one named
97 option (this list will be identical to the corresponding sublist
98 of the value returned if no option is specified). If one or
99 more option-value pairs are specified, then the command modifies
100 the given widget option(s) to have the given value(s); in this
101 case the command returns an empty string. Option may have any
102 of the values accepted by the label command.
103
105 When a new label is created, it has no default event bindings: labels
106 are not intended to be interactive.
107
109 # Make the widgets
110 label .t -text "This widget is at the top" -bg red
111 label .b -text "This widget is at the bottom" -bg green
112 label .l -text "Left\nHand\nSide"
113 label .r -text "Right\nHand\nSide"
114 text .mid
115 .mid insert end "This layout is like Java's BorderLayout"
116 # Lay them out
117 pack .t -side top -fill x
118 pack .b -side bottom -fill x
119 pack .l -side left -fill y
120 pack .r -side right -fill y
121 pack .mid -expand 1 -fill both
122
124 labelframe(n), button(n), ttk::label(n)
125
127 label, widget
128
129
130
131Tk 4.0 label(n)