Python3 Tkinter 实例教学 (十)标签Label 段落末行对齐方式 justify
本节介绍标签设置文本段落末行的对齐方式
Label 作为一个最常用的控件,能够展示一些文本或者图片或者文本和图片的组合使用
构造方法:
Label(父对象, text=“标签内容”, wraplength=换行宽度, justify=末行对齐方式)
justify:left center(默认) right
代码实例:
# -*- coding:utf8 -*-
from tkinter import *
root = Tk()
root.title("Label Demo")
root.geometry("300x150")
label = Label(root, text='人生苦短,我用Python', fg="red", bg="yellow",
height=3, width=30,
wraplength=50, justify="right") # justify 默认为center居中,可选left right center
label.pack()
root.mainloop()