# -*- encoding=utf-8 -*-
import tkinter
from tkinter import *
if __name__ == '__main__':
w = tkinter.Tk()
text = '哈哈哈哈哈哈哈哈哈'
w.geometry('{}x{}+{}+{}'.format(400, 500, 100, 100))
Label(text=text, width=15, relief='g', height=2).pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g', justify='left').pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g', justify='center').pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g', justify='right').pack(pady=(0, 0))
w.mainloop()
3.同时使用对齐方式和换行
# -*- encoding=utf-8 -*-
import tkinter
from tkinter import *
if __name__ == '__main__':
w = tkinter.Tk()
text = '哈哈哈哈哈哈哈哈哈'
w.geometry('{}x{}+{}+{}'.format(400, 500, 100, 100))
Label(text=text, width=15, relief='g', height=2).pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g', justify='left').pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g',anchor='ne', justify='center').pack(pady=(0, 0))
Label(text=text, width=15, wraplength=50, relief='g',anchor='nw', justify='right').pack(pady=(0, 0))
w.mainloop()