Tkinter Message
它的功能是非常类似的标签部件,但它也可以自动换行的文本,维持一个给定的宽度或长宽比.
语法:
这里是一个简单的语法来创建这个widget:
w = Message ( 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 | If you set this option to a cursor name (arrow, dot etc.), the mouse cursor will change to that pattern when it is over the 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 | Width of the label in characters (not pixels!). If this option is not set, the label will be sized to fit its contents. |
| wraplength | You can limit the number of characters in each line by setting this option to the desired number. The default value, 0, means that lines will be broken only at newlines. |
例子:
自行尝试下面的例子:
from Tkinter import * root = Tk() var = StringVar()
label = Message( root, textvariable=var, relief=RAISED ) var.set("Hey!? How are you doing?")
label.pack()
root.mainloop()
这将产生以下结果:

Tkinter Message的更多相关文章
- tkinter中的message
from tkinter import * root =Tk() root.title("message练习") myText = "2019年12月13日,下午一个人, ...
- Python图形编程探索系列-07-程序登录界面设计
设计任务 初步设计程序登录界面,详细分析设计步骤. 程序详细分析 基本框架设计 import tkinter as tk import tkinter.messagebox root = tk.Tk( ...
- Eclipse 4.2 failed to start after TEE is installed
--------------- VM Arguments--------------- jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...
- Tkinter教程之Message篇
本文转载自:http://blog.csdn.net/jcodeer/article/details/1811326 '''Tkinter教程之Message篇'''#Message也是用来显示文本的 ...
- GUI的最终选择 Tkinter(八):Message组件、Spinbox组件、PanedWindow组件、Toplevel组件
Message组件 Message(消息)组件是Label组件的变体,用于显示多行文本消息,Message组件能够自动执行,并调整文本的尺寸使其适应给定的尺寸. from tkinter import ...
- TKinter的常用组件
python提供了多个图形开发界面的库,几个常用Python GUI库如下: Tkinter: Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.T ...
- Python GUI with Tkinter (from youtube) 在youtube上能找到很多编程视频...
Python GUI with Tkinter - 1 - Introduction以上链接是一个python tkinter视频系列的第一讲的链接.虽然英语不好,但是,程序还是看得懂的(照着做就可以 ...
- 串口调试工具(Python2.7+pyserial+Tkinter)
需要与串口设备进行通讯,那么一个调试工具是必须的. 根据我自己的需要,写了个简易版本的串口调试工具: 预览图: ====================== 项目结构: COM --SerialHel ...
- Tkinter类之窗口部件类
Tkinter类之窗口部件类 Tkinter支持15个核心的窗口部件,这个15个核心窗口部件类列表如下:窗口部件及说明:Button:一个简单的按钮,用来执行一个命令或别的操作.Canvas:组织图形 ...
随机推荐
- [转] 用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践
转自知乎上看到的一篇很棒的文章:用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践 近来在同时做一个应用深度学习解决淘宝商品的类目预测问题的项目,恰好硕士毕业时论文 ...
- java 多线程超详细总结——阿里大牛熬夜整理
引 如果对什么是线程.什么是进程仍存有疑惑,请先Google之,因为这两个概念不在本文的范围之内. 用多线程只有一个目的,那就是更好的利用cpu的资源,因为所有的多线程代码都可以用单线程来实现.说这个 ...
- 《PyQt5 快速开发与实战》 第九章代码Bug修正 DataGrid.py 最后一页下翻页 仍可点击的错误
# -*- coding: utf-8 -*- import sys import re from PyQt5.QtWidgets import (QWidget , QHBoxLayout , QV ...
- 并查集实现Tarjan算法
本文是对http://noalgo.info/476.html的一点理解,特别是对其中 int father[mx]: //节点的父亲 int ancestor[mx]; //已访问节点集合的祖先 这 ...
- [译]缓解BEAST对TLS攻击的方式
原文链接:https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls 原 ...
- appium python实例脚本1
#coding=utf-8import os, time, unittestfrom appium import webdriver PATH = lambda p:os.path.abspath(o ...
- python 判断类型
转自:http://san-yun.iteye.com/blog/1543174 Python可以得到一个对象的类型 ,利用type函数: >>>lst = [1, 2, 3] &g ...
- __getitem__ 专用方法
(1) __getitem__ 专用方法很简单.像普通的方法 clear,keys 和 values 一样,它只是重定向到字典,返回字典的值.但是怎么调用它呢?哦,你可以直接调用 __getitem ...
- 基于spring的异常一站式解决方案
https://segmentfault.com/a/1190000006749441#articleHeader4 https://lrwinx.github.io/2016/04/28/%E5%A ...
- 2.JMeter查看结果树返回编码格式Unicode转为中文方法
在使用JMeter做接口测试时,发现相同url,用postman工具,其返回数据参数为中文,而用JMeter工具,其返回参数为Unicode,如下图所示 解决方法如下: 1.Jmeter在对应的请求上 ...