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. IE11降级到IE8

  2. 04-python第四天学习

    (1)for循环里的else In [1]: nums = [11,22,33,44] In [2]: for temp in nums: ...: print(temp) ...: else: #e ...

  3. mysql在innodb索引下b+树的高度问题。

    B+树索引介绍 B+树索引的本质是B+树在数据库中的实现.但是B+树索引有一个特点是高扇出性,因此在数据库中,B+树的高度一般在2到3层.也就是说查找某一键值的记录,最多只需要2到3次IO开销.按磁盘 ...

  4. cocos2d-x 发布win32 release版本后找不到msvcr110.dll

    解决方法: 安装Visual C++ Redistributable for Visual Studio 2012 //下载地址 http://www.microsoft.com/zh-CN/down ...

  5. Python 实现windows后台服务

    # -*- coding: utf-8 -*- import sys import win32api import win32con import win32event import win32ser ...

  6. 使用 Task.Wait()?立刻死锁(deadlock)

    最近读到一篇异步转同步的文章,发现其中没有考虑到异步转同步过程中发生的死锁问题,所以特地在本文说说异步转同步过程中的死锁问题. 文章作者 林德熙 已经修复了描述: - win10 uwp 异步转同步 ...

  7. C++ set容器

    STL中的set容器的一点总结:(元素唯一,且排序) 1.关于set (头文件:<set>) C++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, strin ...

  8. 洛谷 P2828 Switching on the Lights(开关灯)

    传送门 题目大意:n*n的网格,每个网格是一个房间 都关着灯,只有(1,1)开着灯,且(x,y)有着(z,k)房间灯的开关. 问从(1,1)开始走最多点开几盏灯. 题解:搜索+骗分. 劳资的骗分天下无 ...

  9. webpack 图片资源处理

    备注:  css 引用图片资源 1. 安装loader yarn add file-loader --dev 2. 配置 const path = require("path"); ...

  10. sysbench fileio 压力测试

    备注:   使用的是yum 安装   1. 安装 yum install -y sysbench 2. 命令 fileio options: --file-num=N number of files ...