tkinter 3 Message

Reference

简介

Message组件是 Label 组件的变体,也是用来显示文本的,用法与Label基本一样。它多用于显示多行文本消息。Message 组件能够自动换行,并调整文本的尺寸使其适应给定的尺寸

使用:Message 组件用于显示简单的文本消息,通常你可以使用 Label 来代替。如果你希望使用多种字体来显示文本,那么应该使用 Text 组件。

属性

实例

def test1(master=None):
    v = StringVar()
    v.set('Hello world, hello')
    Message(master, bg='black', fg='red',
            anchor='e',
            textvariable=v,
            aspect=200,
            justify=LEFT).pack()
    msg2 = Message(master, bg='grey', fg='blue',
                   anchor='e',
                   text="Hi, how are you?",
                   width=100,
                   justify=RIGHT)
    msg2.pack()

    def call_back():
        v.set("/Users/shao/Applications/anaconda3/envs/PyAppDev-basic/bin/python "
              "/Users/shao/Developer/PycharmProjects/stu_tkinter/03_message.py")
        msg2["text"] = "We don't talk anymore, we don't love anymore, " \
                       "we don't talk anymore like we use to do"

    Button(master, text="click", bd=10, relief=RIDGE, command=call_back).pack()
Table of Contents