Text widget hỗ trợ nhiều dòng, màu sắc, hyperlink. Xóa nội dung bằng delete("1.0", END) trong callback nút bấm.
Ví dụ
# Import thư viện
from tkinter import *
# Tạo khung
win = Tk()
win.geometry("750x250")
# Hàm xóa text
def clear():
text.delete('1.0', END)
# Text widget
text = Text(win, width=50, height=10)
text.insert("1.0", "This is my Text Widget")
text.pack(padx=5, pady=5)
# Nút xóa
Button(win, text="Clear All", command=clear, font="aerial 12 bold").pack(padx=5, pady=5)
win.mainloop()Kết quả
Text widget và nút Clear All. Click nút xóa hết nội dung.

