Tkinter Message 使用字符串变量处理text参数

Tkinter Message 使用字符串变量处理text参数

示例1

以字符串变量方式处理Message( )内的text。

from tkinter import *

root = Tk()
root.title("apidemos.com")

var = StringVar()
msg = Message(root,textvariable=var,relief=RAISED)
var.set(
        """apidemos.com provides tutorials on the basics of programming, introducing the basics of various programming languages such as HTML, CSS, Javascript, Python, Java, Ruby, C, PHP , MySQL and more. The site also provides a large number of online examples, through the examples, you can better learn programming..."""
)
msg.pack(padx=10,pady=10)

root.mainloop()

输出:

Tkinter Message 使用字符串变量处理text参数

示例2

扩充上述实例,将背景设为黄色。

from tkinter import *

root = Tk()
root.title("apidemos.com")

var = StringVar()
msg = Message(root,textvariable=var,relief=RAISED,font="times 30 italic")
var.set(
        """apidemos.com provides tutorials on the basics of programming, introducing the basics of various programming languages such as HTML, CSS, Javascript, Python, Java, Ruby, C, PHP , MySQL and more. The site also provides a large number of online examples, through the examples, you can better learn programming..."""
)
msg.config(bg="yellow")
msg.pack(padx=10,pady=10)

root.mainloop()

输出:

Tkinter Message 使用字符串变量处理text参数

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程