Python3 Tkinter 实例教学 (八)标签Label 设置换行宽度
本节介绍标签设置文本换行宽度
Label 作为一个最常用的控件,能够展示一些文本或者图片或者文本和图片的组合使用
构造方法:
Label(父对象, text=“标签内容”, wraplength=40)
wraplength:换行宽度 单位 像素
代码实例:
# -*- coding:utf8 -*-
from tkinter import *
root = Tk()
root.title("Label Demo")
root.geometry("300x150")
label = Label(root, text='a a a a a a a a a', fg="red", bg="yellow",
height=3, width=30,
anchor=NW, wraplength=40) # 换行宽度40像素
label.pack()
root.mainloop()