Python 3 Tkinter Remove or Erase all Data From Text or Listbox Widget GUI Desktop App Full Project For Beginners



# Import the required libraries
from tkinter import *

# Create an instance of Tkinter Frame
win = Tk()

# Set the geometry

# Define a function to clear the text widget
def clear():
   text.delete('1.0', END)

# Create a Text Widget
text = Text(win, width=50, height=10)
text.insert("1.0", "This is my Text Widget")
text.pack(padx=5, pady=5)

# Create a Button to delete all the text
Button(win, text="Clear All", command=clear, font="aerial 12 bold").pack(padx=5, pady=5)


Leave a Reply