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

 

 

 

main.py

 

 

# Import the required libraries
from tkinter import *

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

# Set the geometry
win.geometry("750x250")

# 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)

win.mainloop()

Leave a Reply