标签和按钮类似,但是标签不做任何动作,只是提示,它不是一个交互的部件,
你点击它,它不会有任何操作
创建标签:
创建标签的语法:
$label = $parent->Label( [ option => value . . . ] )->pack( );
Label Options
The following is a comprehensive list of options for Labels:
下面列出所有标签的选项:
-anchor => 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'center'
Causes the text to stick to that position in the Label widget. This won't be obvious unless the Label is forced to be larger than standard size.
将文本放在什么位置,主要是当我们的界面很大的时,位置设置特别重要
-background => color
Sets the background color of the Label to color.
设置文字的背景颜色
-bitmap => bitmap
Displays the bitmap contained in bitmap instead of text.
以bitmap图象取代Label中的文字显示,里面放置图象的路径和名称
-borderwidth => amount
Changes the width of the edges of the Label.
设定标签的边框宽度
-cursor => cursorname
Changes the cursor to cursorname when the mouse is over this widget.
改变鼠标放在标签上时鼠标改变成cursorname的样子
-font => fontname
Indicates that the text in the widget will be displayed with fontname.
设定标签的字型
-foreground => color
Changes the text of the Button (or the bitmap) to color.
设定文字的颜色
-height => amount
Sets the height of the Label to amount; amount is a valid screen distance.
设定标签的高度,设定的值应该是屏幕的有效范围
-highlightbackground => color
Sets the color of the focus rectangle when the widget is not in focus to color.
10
当标签不是键盘输入焦点时,设定其颜色
-highlightcolor => color
Sets the color of the focus rectangle when the widget has focus to color.
当标签成为键盘输入焦点时,设定其颜色
-highlightthickness => amount
Sets the width of the focus rectangle. Default is 0 for the Label.
设定焦点的宽度,默认值为0
-image => imgptr
Displays the image to which imgptr points, instead of text.
指定以image取代文字的显示
-justify => 'left' | 'right' | 'center'
Sets the side of the Label against which multiline text will justify.
让多行文字向那个方向对齐
-padx => amount
Adds extra space inside the edge to the left and right of the Label.
在label框线内的左右两边增加额外的空间
-pady => amount
Adds extra space inside the edge to the top and bottom of the Label.
在label框线内的上下两边增加额外的空间
-relief => 'flat' | 'groove' | 'raised' | 'ridge' | 'sunken'
Changes the type of edges drawn around the Button.
设置标签的3D效果
-takefocus => 0 | 1 | undef
Changes the ability of the Label to have the focus or not.
是否让label成为键盘的输入焦点
-text => text
Displays a text string in the Label.
设定显示的文字内容
-textvariable => $variable
Points to the variable containing text to be displayed in the Label. Label will change automatically as $variable changes.
设定变动文字的内容
-underline => n
Causes the nth character to be underlined. Allows that key to invoke the widget when it has the focus. Default value is -1 (no character underlined).
将某些字设定有下划线,默认值为-1
-width => amount
Causes the Label width to be amount.
设定标签的宽度
-wraplength => amount
Indicates that the text in the Label will wrap when it gets longer than amount.
当文字串的宽度超出多少限制后,换至下行显示
单行文本:
到目前为止,我们知道的唯一的输入方式是用户点击按钮得到,
通过按钮的-command选项得到信息毕竟是有限的,文本部件让用户输入文本,
可以用于各种各样的需求信息。