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:组织图形 ...
随机推荐
- angular 与jQuery混用 大坑一
由于angular是在真实dom加载之后,运行,所以jQuery操作dom时,要先于angular添加的元素(如,ng-repeat),所以常常会出现,元素错位,解决办法:添加一个透明的站位元素:
- spring boot入门教程——Spring Boot快速入门指南
Spring Boot已成为当今最流行的微服务开发框架,本文是如何使用Spring Boot快速开始Web微服务开发的指南,我们将使创建一个可运行的包含内嵌Web容器(默认使用的是Tomcat)的可运 ...
- vuex(一)mutations
前言:vuex的使用,想必大家也都知道,类似于状态库的东西,存储某种状态,共互不相干的两个组件之间数据的共享传递等.我会分开给大家讲解vuex的使用,了解并掌握vuex的核心(state,mutati ...
- HDU1003 Max Sum
解题思路:最大连续和,此题多了记录的下标,具体见代码. #include<cstdio> #include<algorithm> using namespace std; #d ...
- BZOJ2216 Poi2011 Lightning Conductor 【决策单调性优化DP】
Description 已知一个长度为n的序列a1,a2,...,an. 对于每个1<=i<=n,找到最小的非负整数p满足 对于任意的j, aj < = ai + p - sqrt( ...
- 《DSP using MATLAB》示例Example 8.27
%% ------------------------------------------------------------------------ %% Output Info about thi ...
- CH1803 City Game
题意 这片土地被分成NM个格子,每个格子里写着'R'或者'F',R代表这块土地被赐予了rainbow,F代表这块土地被赐予了freda. 现在freda要在这里卖萌...它要找一块矩形土地,要求这片土 ...
- drone 学习一 几个核心组件
1. clone 这个是内置的,实际上就行进行代码clone的 参考配置,同时我们可以使用自定义的插件 clone: + git: + image: plugins/git pipeline: bui ...
- 使用PHP类库PHPqrCode生成二维码
PHPqrCode是一个PHP二维码生成类库,利用它可以轻松生成二维码,官网提供了下载和多个演示demo, 查看地址:http://phpqrcode.sourceforge.net/. 下载官 ...
- CSS样式属性分类
A 文字 1 font-family:字体名称 注意: 当指定多种字体时,用“,”分隔每种字体的名称 当字体名称包含两个以上分开的单词是,用“”把该字体名称括起来. 当样式规则外已经有“”时,用‘’代 ...