Tkinter Label(标签)
它也可能强调文本的一部分(要确定一个键盘快捷键),跨越多行文本.
语句:
这里是一个简单的语法来创建这个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(标签)的更多相关文章
- Tkinter 之Label标签
一.参数说明 语法 作用 Label(window,text=‘xxxxx’) 需要在界面显示的Label标签内容 Label(window,text=‘xxxxx’,height=2) 组件的高度( ...
- python tkinter Label
"""小白随笔,大佬勿喷""" #Label标签 用于可显示文本或图片,不可编辑 import tkinter as tk #初始化窗口 w ...
- WPF自定义控件与样式(3)-TextBox & RichTextBox & PasswordBox样式、水印、Label标签、功能扩展
一.前言.预览 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要是对文本 ...
- HTML label标签的一点理解
label标签为input元素定义标注. label元素不呈现任何特殊效果.不过他为鼠标用户改进了可用性.如果你在label元素内点击文本就会触发此控件.就是说当用户选择该标签是,浏览器就会自动的将焦 ...
- HTML <label> 标签
定义:<label> 标签为 input 元素定义标注(标记). 用法: label 元素不会向用户呈现任何特殊效果.不过,它为鼠标用户改进了可用性.如果您在 label 元素内点击文本, ...
- label标签使用过程中遇到的问题
最近在做东西时候使用到了label标签,由于之前很少使用label标签,所以就遇到一个很奇怪的问题.什么问题呢?下面来看一个效果 <!DOCTYPE html> <html> ...
- [Cocos2D-x For WP8]Label标签
Label标签主要会用于在游戏中显示一些文字字符串类型的信息.那么在Cocos2D-x里面主要会有下面的一些创建标签的方式: 1.使用CCLabelTTF类生成系统文字的标签,编程语法如下: CCLa ...
- [HTML5]label标签使用以及建议
for 属性规定 label 与哪个表单元素绑定. 隐式和显式的联系 标记通常以下面两种方式中的一种来和表单控件相联系:将表单控件作为标记标签的内容,这样的就是隐式形式,或者为 <label&g ...
- label标签跳出循环
出场: 首先我们来说说为什么需要label标签,虽然我们已经知道有break,continue跳出循环,但如果是多重循环那么它们就显的无能为力了,所以就出现了label这个标签来为我们服务. 我们先来 ...
随机推荐
- memcached asp.net
下载文件 memcached 1.解压缩文件到e:\memcached 2.命令行输入 e:\memcached\memcached.exe -d install' 3.命令行输入 e:\memcac ...
- JavaScript class 使用
/********************************************************************* * JavaScript class 使用 * 说明: * ...
- 自回归模型(AR )
2017/7/2 19:24:15 自回归模型(Autoregressive Model,简称 AR 模型)是最常见的平稳时间序列模型之一.接下将介绍 AR 模型的定义.统计性质.建模过程.预测及应用 ...
- 【解题报告】13级个人结业赛(二) ——动(dou)态(bu)规(hui)划(zuo)专场
额.果然是动(dou)态(bu)规(hui)划(zuo)专场... A: 翻倍序列 dp[i][j]表示第i个位置是j的情况的个数那么dp[i][j]=∑dp[i-1][k] (j%k==0)初始 ...
- 使用HttpURLConnection请求multipart/form-data类型的form提交
写一个小程序,模拟Http POST请求来从网站中获取数据.使用Jsoup(http://jsoup.org/)来解析HTML. Jsoup封装了HttpConnection的功能,可以向服务器提交请 ...
- apue 2ed 和 unp 3ed 环境配置
网上虽然有很多配置攻略,但是依然会一头雾水,下面记录我的配置过程. OS. Ubuntu 10.04 LTS 5 首先下载APUE源代码(http://www.apuebook.com/src.tar ...
- 使用POI对excel进行操作生成二维数组
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import ja ...
- BZOJ - 3223 Tyvj 1729 文艺平衡树 (splay/无旋treap)
题目链接 splay: #include<bits/stdc++.h> using namespace std; typedef long long ll; ,inf=0x3f3f3f3f ...
- LOJ2422 NOIP2015 斗地主 【搜索+贪心】*
LOJ2422 NOIP2015 斗地主 LINK 题目大意很简单,就是问你斗地主的一分手牌最少多少次出完 然后我们发现对于一种手牌状态,不考虑顺子的情况是可以贪心做掉的 然后我们直接枚举一下顺子出牌 ...
- python笔记-7(shutil/json/pickle/shelve/xml/configparser/hashlib模块)
一.shutil模块--高级的文件.文件夹.压缩包处理模块 1.通过句柄复制内容 shutil.copyfileobj(f1,f2)对文件的复制(通过句柄fdst/fsrc复制文件内容) 源码: Le ...