消息和标签的区别?(tkinter) [英] Message and Label Difference? (tkinter)

查看:44
本文介绍了消息和标签的区别?(tkinter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白的是消息和标签之间有什么区别.他们看起来非常相似.有没有人可以澄清一下?

我不是在谈论消息框小部件.我只是对消息和标签小部件

有疑问

代码语法是这样的 -

M1 = Message(root,options...)L1 = 标签(根,选项...)

它们看起来与输出非常相似.

解决方案

本文来自 消息小部件的规范描述:

<块引用>

消息是显示文本字符串的小部件.消息小部件具有三个区别于标签小部件的特殊功能.首先,它将其字符串分解成行,以便为窗口生成给定的纵横比.尽可能在单词边界处选择换行符(如果一行中连一个单词都放不下,那么单词将跨行拆分).字符串中的换行符会强制换行;例如,它们可用于在显示中留下空白行.

<块引用>

消息小部件的第二个功能是理由.文本可以左对齐(每行从窗口左侧开始)、逐行居中或右对齐(每行在窗口右侧结束)显示.

<块引用>

消息小部件的第三个特点是它专门处理控制字符和非打印字符.制表符被替换为足够的空格以在下一个 8 个字符的边界上排列.换行会导致换行.其他控制字符(小于 0x20 的 ASCII 码)和字体中未定义的字符显示为四字符序列 \xhh,其中 hh 是与字符对应的两位十六进制数.如果字体不包含0123456789abcdef\x"中的所有字符,那么控制字符和未定义字符根本不会显示.

What I don't understand is what is the difference between a message and a label. They look so much similar. Is there anyone who can clarify this?

I am not talking about the message box widget. I just had a doubt about the message and label widget

The code syntax is something like this -

M1 = Message(root,options...)
L1 = Label(root,options...)

They look so similar as a output.

解决方案

This is from the canonical description of the message widget:

A message is a widget that displays a textual string. A message widget has three special features that differentiate it from a label widget. First, it breaks up its string into lines in order to produce a given aspect ratio for the window. The line breaks are chosen at word boundaries wherever possible (if not even a single word would fit on a line, then the word will be split across lines). Newline characters in the string will force line breaks; they can be used, for example, to leave blank lines in the display.

The second feature of a message widget is justification. The text may be displayed left-justified (each line starts at the left side of the window), centered on a line-by-line basis, or right-justified (each line ends at the right side of the window).

The third feature of a message widget is that it handles control characters and non-printing characters specially. Tab characters are replaced with enough blank space to line up on the next 8-character boundary. Newlines cause line breaks. Other control characters (ASCII code less than 0x20) and characters not defined in the font are displayed as a four-character sequence \xhh where hh is the two-digit hexadecimal number corresponding to the character. In the unusual case where the font does not contain all of the characters in "0123456789abcdef\x" then control characters and undefined characters are not displayed at all.

这篇关于消息和标签的区别?(tkinter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆