Coding Tutorials Hub

Learn coding with simple code, clear explanations, and examples

Python TKinter GUI - Entry Widget [textbox] delete/clear text

📄 Code


import tkinter as tk

def delete_text():
    textbox.delete(0, tk.END)

# Create the main window
root = tk.Tk()
root.title("Tkinter-GUI textbox Tutorial")
root.geometry("300x100")

# Create a single-line input textbox
textbox = tk.Entry(root)
textbox.pack(pady=10)

# Create a button
button = tk.Button(root, text="Click to clear textbox text", command=delete_text)
button.pack(pady=5)

# Run the application
root.mainloop()
        
💡 Output