Tkinter Label : 这个小工具,实现了显示框,在那里你可以把文本或图像。这个widget中显示的文本可以在任何时候你想要更新.
 
这个小工具,实现了显示框,在那里你可以把文本或图像。这个widget中显示的文本可以在任何时候你想要更新.

它也可能强调文本的一部分(要确定一个键盘快捷键),跨越多行文本.

语句:

这里是一个简单的语法来创建这个widget:

 w = Label ( master, option, ... )

参数:

  • master: 这代表了父窗口.

  • options: 下面是这个小工具最常用的选项列表。这些选项可以作为键 - 值对以逗号分隔.

Option Description
anchor 此选项控制文本的位置,如果部件比文本,还需要有更多的空间。默认为锚=中心,该中心可用空间的文本.
bg The normal background color displayed behind the label and indicator.
bitmap Set this option equal to a bitmap or image object and the label will display that graphic.
bd The size of the border around the indicator. Default is 2 pixels.
cursor 如果将此选项设置为游标名称(箭头,点等),鼠标光标会改变这种模式时,它超过了checkbutton.
font If you are displaying text in this label (with the text or textvariable option, the font option specifies in what font that text will be displayed.
fg If you are displaying text or a bitmap in this label, this option specifies the color of the text. If you are displaying a bitmap, this is the color that will appear at the position of the 1-bits in the bitmap.
height The vertical dimension of the new frame.
image To display a static image in the label widget, set this option to an image object.
justify Specifies how multiple lines of text will be aligned with respect to each other: LEFT for flush left, CENTER for centered (the default), or RIGHT for right-justified.
padx Extra space added to the left and right of the text within the widget. Default is 1.
pady Extra space added above and below the text within the widget. Default is 1.
relief Specifies the appearance of a decorative border around the label. The default is FLAT; for other values.
text To display one or more lines of text in a label widget, set this option to a string containing the text. Internal newlines ("\n") will force a line break.
textvariable To slave the text displayed in a label widget to a control variable of classStringVar, set this option to that variable.
underline You can display an underline (_) below the nth letter of the text, counting from 0, by setting this option to n. The default is underline=-1, which means no underlining.
width 宽字符(而不是像素)的标签。如果未设置此选项,将大小以适应其内容标签.
wraplength 你可以将此选项设置为所需的数量限制在每行的字符数。默认值为0,意味着线只换行符将被打破,.

例子:

自行尝试下面的例子:

from Tkinter import *

root = Tk()

var = StringVar()
label = Label( root, textvariable=var, relief=RAISED ) var.set("Hey!? How are you doing?")
label.pack()
root.mainloop()

这将产生以下结果:

Tkinter Label(标签)的更多相关文章

  1. Tkinter 之Label标签

    一.参数说明 语法 作用 Label(window,text=‘xxxxx’) 需要在界面显示的Label标签内容 Label(window,text=‘xxxxx’,height=2) 组件的高度( ...

  2. python tkinter Label

    """小白随笔,大佬勿喷""" #Label标签 用于可显示文本或图片,不可编辑 import tkinter as tk #初始化窗口 w ...

  3. WPF自定义控件与样式(3)-TextBox & RichTextBox & PasswordBox样式、水印、Label标签、功能扩展

    一.前言.预览 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要是对文本 ...

  4. HTML label标签的一点理解

    label标签为input元素定义标注. label元素不呈现任何特殊效果.不过他为鼠标用户改进了可用性.如果你在label元素内点击文本就会触发此控件.就是说当用户选择该标签是,浏览器就会自动的将焦 ...

  5. HTML <label> 标签

    定义:<label> 标签为 input 元素定义标注(标记). 用法: label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label 元素内点击文本, ...

  6. label标签使用过程中遇到的问题

    最近在做东西时候使用到了label标签,由于之前很少使用label标签,所以就遇到一个很奇怪的问题.什么问题呢?下面来看一个效果 <!DOCTYPE html> <html> ...

  7. [Cocos2D-x For WP8]Label标签

    Label标签主要会用于在游戏中显示一些文字字符串类型的信息.那么在Cocos2D-x里面主要会有下面的一些创建标签的方式: 1.使用CCLabelTTF类生成系统文字的标签,编程语法如下: CCLa ...

  8. [HTML5]label标签使用以及建议

    for 属性规定 label 与哪个表单元素绑定. 隐式和显式的联系 标记通常以下面两种方式中的一种来和表单控件相联系:将表单控件作为标记标签的内容,这样的就是隐式形式,或者为 <label&g ...

  9. label标签跳出循环

    出场: 首先我们来说说为什么需要label标签,虽然我们已经知道有break,continue跳出循环,但如果是多重循环那么它们就显的无能为力了,所以就出现了label这个标签来为我们服务. 我们先来 ...

随机推荐

  1. iOS开发:UITableView的优化技巧-异步绘制Cell

    最近在微博上看到一个很好的开源项目VVeboTableViewDemo,是关于如何优化UITableView的.加上正好最近也在优化项目中的类似朋友圈功能这块,思考了很多关于UITableView的优 ...

  2. .pyc和.pyo文件有何用

    百度知道:http://zhidao.baidu.com/link?url=_tFP1xglFnoEBObWtIArI3b3Ft0PQowx5m5ruIaX3mFIAFVr7vX45Lfb0geCjA ...

  3. Servlet实现验证码图片(一)

    Servlet实现数字字母验证码图片(一): 生成验证码图片主要用到了一个BufferedImage类,如下:

  4. CF1109A Sasha and a Bit of Relax

    CF1109A Sasha and a Bit of Relax 用 \(xorsum[l,r]\) 表示 \(a[l] \oplus a[l+1] \oplus a[l+2]... a[r-1] \ ...

  5. BZOJ2595 Wc2008 游览计划 【斯坦纳树】【状压DP】*

    BZOJ2595 Wc2008 游览计划 Description Input 第一行有两个整数,N和 M,描述方块的数目. 接下来 N行, 每行有 M 个非负整数, 如果该整数为 0, 则该方块为一个 ...

  6. mysql拼接多条查询结果并且加序列

    SELECT GROUP_CONCAT(a.DESCRIPTION SEPARATOR '\n')     FROM (SELECT (@rowNum:=0) AS rowNo,CONCAT('公司内 ...

  7. 《DSP using MATLAB》示例Example 8.8

    %% ------------------------------------------------------------------------ %% Output Info about thi ...

  8. 在linux修改文件夹及其子文件夹的权限。

    加入-R 参数,就可以将读写权限传递给子文件夹例如chmod -R 777 /home/mypackage那么mypackage 文件夹和它下面的所有子文件夹的属性都变成了777.777是读.写.执行 ...

  9. bzoj 4816 [Sdoi2017]数字表格——反演

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4816 \( ans=\prod\limits_{d=1}^{n}f[d]^{\sum\lim ...

  10. BZOJ3261:最大异或和

    浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:https://lydsy.com/JudgeOnline/problem ...