Tkinter Reset Button: Clear Form Inputs and Selections

To clear a Tkinter form, connect the Reset button to a function that checks each widget and clears its value. Use winfo_children() to get the widgets, isinstance() to identify their types, and the appropriate reset method for each type.

def my_reset():
    for widget in my_w.winfo_children():
        if isinstance(widget, ttk.Combobox):
            widget.set("")
        elif isinstance(widget, tk.Entry):
            widget.delete(0, tk.END)
        elif isinstance(widget, tk.Text):
            widget.delete("1.0", tk.END)
        elif isinstance(widget, tk.Checkbutton):
            widget.deselect()
    year_var.set("")  # Clear the Radiobutton group

Place this function inside your Tkinter application after creating my_w and the variable year_var. A complete runnable program is provided below.

Tkinter form with Reset button for Entry, Text, Combobox, Checkbutton and Radiobutton controls

Reset methods for Tkinter input widgets 🔝

Different widgets need different methods. A single call to delete() does not work for every Tkinter control.

WidgetMethod to resetWhat happens
tk.Entrydelete(0, tk.END)Clears the single-line input
ttk.Comboboxset("")Removes the displayed selection
tk.Textdelete("1.0", tk.END)Deletes multiline content
tk.Checkbuttondeselect()Unchecks the box
tk.Radiobuttonvariable.set("")Clears the shared selected value

winfo_children() returns only widgets directly contained in the specified parent. For controls inside Frames, use the recursive method shown later.

Clear all Entry widgets 🔝

To clear multiple Entry widgets, loop through the parent's child widgets and apply delete(0, tk.END) to each Entry. The same code works whether there are two Entry fields or twenty.

for widget in my_w.winfo_children():
    if isinstance(widget, tk.Entry):
        widget.delete(0, tk.END)

Here, 0 identifies the first character, while tk.END refers to the end of the text.

Clear a ttk.Combobox 🔝

A Combobox belongs to ttk. Using set("") clears its displayed value, including when the widget was created with state="readonly".

for widget in my_w.winfo_children():
    if isinstance(widget, ttk.Combobox):
        widget.set("")

The dropdown choices remain available; only the current selection is cleared. To select a known default instead, use widget.set("Jan") or another value in its list.

Clear a multiline Text widget 🔝

The Text widget uses line-and-character indices. Its content starts at "1.0", not index 0 as in an Entry.

for widget in my_w.winfo_children():
    if isinstance(widget, tk.Text):
        widget.delete("1.0", tk.END)

Using delete(0, "end") on a Text widget can raise a Tcl index error. Always start from "1.0".

Uncheck Checkbuttons 🔝

For ordinary tk.Checkbutton widgets, deselect() removes a selected check mark. This also updates the widget's associated control variable.

for widget in my_w.winfo_children():
    if isinstance(widget, tk.Checkbutton):
        widget.deselect()

If you use ttk.Checkbutton, it is often simpler to store the selection in a BooleanVar and reset the variable to False (shown later).

Reset Radiobutton selections 🔝

All Radiobuttons in the same selection group share a Tkinter variable. Set that variable to an empty string to remove the selection when none of the option values is empty.

year_var = tk.StringVar(value="year2")
# Both Radiobutton widgets share year_var.
year_var.set("")  # Neither option is selected

Using StringVar.set(None) does not store a real Python None value inside Tcl; for a no-selection state, an empty string is clearer. Use a distinct sentinel if "" is a valid option value.

Complete Tkinter form with Submit and Reset buttons 🔝

The complete program creates two Entry fields, a month Combobox, a multiline Text field, two Checkbuttons, a pair of Radiobuttons, and two buttons. Try entering values and then click Reset: all text fields and selections return to an empty state. The Submit button displays the current values.

Save the program as tkinter_reset.py and run it with a local Python installation that supports Tkinter. Native Tkinter windows require a desktop display, so this example is intended for a computer rather than a hosted notebook.

import tkinter as tk
from tkinter import ttk, messagebox

my_w = tk.Tk()
my_w.title("Tkinter Reset Button - plus2net")
my_w.geometry("500x430")
my_w.columnconfigure(1, weight=1)

# Widgets that accept user input
first_name = tk.Entry(my_w, font=("Arial", 12))
last_name = tk.Entry(my_w, font=("Arial", 12))
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
month_box = ttk.Combobox(my_w, values=months, state="readonly")
notes = tk.Text(my_w, height=3, width=32, bg="lightyellow")

agree = tk.Checkbutton(my_w, text="I Agree")
newsletter = tk.Checkbutton(my_w, text="Newsletter")
year_var = tk.StringVar(value="year2")
year1 = tk.Radiobutton(my_w, text="Year 1", value="year1", variable=year_var)
year2 = tk.Radiobutton(my_w, text="Year 2", value="year2", variable=year_var)

def my_reset():
    for widget in my_w.winfo_children():
        if isinstance(widget, ttk.Combobox):
            widget.set("")
        elif isinstance(widget, tk.Entry):
            widget.delete(0, tk.END)
        elif isinstance(widget, tk.Text):
            widget.delete("1.0", tk.END)
        elif isinstance(widget, tk.Checkbutton):
            widget.deselect()
    year_var.set("")  # Reset the complete Radiobutton group

def show_values():
    messagebox.showinfo("Form values", f"First name: {first_name.get()}\n"
                        f"Last name: {last_name.get()}\n"
                        f"Month: {month_box.get()}\n"
                        f"Year: {year_var.get()}")

# Arrange all widgets directly inside my_w.
tk.Label(my_w, text="First Name").grid(row=0, column=0, padx=10, pady=8, sticky="w")
first_name.grid(row=0, column=1, padx=10, pady=8, sticky="ew")
tk.Label(my_w, text="Last Name").grid(row=1, column=0, padx=10, pady=8, sticky="w")
last_name.grid(row=1, column=1, padx=10, pady=8, sticky="ew")
tk.Label(my_w, text="Month").grid(row=2, column=0, padx=10, pady=8, sticky="w")
month_box.grid(row=2, column=1, padx=10, pady=8, sticky="w")
tk.Label(my_w, text="Notes").grid(row=3, column=0, padx=10, pady=8, sticky="nw")
notes.grid(row=3, column=1, padx=10, pady=8, sticky="ew")
agree.grid(row=4, column=0, padx=10, pady=5)
newsletter.grid(row=4, column=1, padx=10, pady=5)
year1.grid(row=5, column=0, padx=10, pady=5)
year2.grid(row=5, column=1, padx=10, pady=5)
tk.Button(my_w, text="Submit", command=show_values).grid(row=6, column=0, pady=15)
tk.Button(my_w, text="Reset", bg="lightpink", command=my_reset).grid(row=6, column=1, pady=15)

my_w.mainloop()

Expected result

Clicking Reset clears First Name, Last Name, Month, and Notes; unchecks both Checkbuttons; and removes the selection from both Radiobuttons. The remaining labels and buttons stay on screen.

Important: This example puts each input widget directly inside my_w. If your real form groups controls inside Frames or tabs, use a recursive widget traversal.

Video: Reset a Tkinter form using winfo_children() 🔝

Tkinter Reset button to remove all user input data and selections from widgets by winfo_children()

Reset widgets inside Frames and nested containers 🔝

Widgets inside a Frame, LabelFrame, or notebook tab are not direct children of the main window. Use a recursive generator to visit every descendant. This snippet is suitable for use after those widgets have been created.

def all_children(parent):
    for child in parent.winfo_children():
        yield child
        yield from all_children(child)

for widget in all_children(my_w):
    if isinstance(widget, ttk.Combobox):
        widget.set("")
    elif isinstance(widget, (tk.Entry, ttk.Entry)):
        widget.delete(0, tk.END)
    elif isinstance(widget, tk.Text):
        widget.delete("1.0", tk.END)

For selection widgets, also reset any associated StringVar, IntVar, or BooleanVar values. The snippet focuses on text-entry controls; you can extend it using the methods in the reference table above.

Restore default values instead of clearing everything 🔝

Sometimes Reset should return the form to its starting values rather than leave all fields empty. After clearing an Entry, insert its default text, set a Combobox option, or restore the initial Radiobutton choice.

# Restore the original default values instead of leaving fields empty.
first_name.delete(0, tk.END)
first_name.insert(0, "Guest")
month_box.set("Jan")
year_var.set("year2")

Reset ttk.Checkbutton using BooleanVar

When using themed Checkbuttons, manage their selection through a variable. The checkbox reflects the variable's current Boolean value.

# For ttk.Checkbutton, control the check state with a variable.
selected = tk.BooleanVar(value=True)
check = ttk.Checkbutton(my_w, text="Newsletter", variable=selected)
selected.set(False)  # Clear the selection

Reset a disabled Entry widget

An Entry in the disabled state cannot be edited normally. Temporarily enable it, clear the text, and then restore its previous state. Apply this only when clearing a disabled field is intentional.

# Temporarily enable a disabled Entry before clearing its content.
old_state = first_name.cget("state")
first_name.configure(state="normal")
first_name.delete(0, tk.END)
first_name.configure(state=old_state)

Common errors and troubleshooting 🔝

ProblemCause and solution
Text widget raises an invalid index errorUse delete("1.0", tk.END) instead of delete(0, tk.END).
Some fields do not clearwinfo_children() only returns immediate children. Visit nested Frames recursively.
Combobox stays selectedUse set("") to clear its displayed value. For a default, set an allowed selection.
Radiobutton selection remainsReset the variable shared by the Radiobutton group, not each widget individually.
Reset button has no effectPass the function as command=my_reset. Do not call it during button creation with command=my_reset().
Disabled input cannot be clearedTemporarily change its state to normal, clear it, and restore the original state.
A ttk.Checkbutton is not detectedttk.Checkbutton is a different class from tk.Checkbutton. Reset its variable, or handle its themed widget state.

Frequently asked questions 🔝

Can one Reset button clear multiple Tkinter Entry widgets?

Yes. Loop over winfo_children(), identify each Entry with isinstance(), and call delete(0, tk.END). Use recursion if the widgets are nested.

What is the difference between Entry.delete() and Text.delete()?

An Entry starts at character index 0. A Text widget starts at line and character index "1.0".

Will clearing a Combobox remove its dropdown values?

No. set("") removes the current displayed value while keeping the list of choices.

How do I make Reset restore the initial selection?

Store your initial values and assign them again within the reset function, such as year_var.set("year2") or month_box.set("Jan").

Can the complete Tkinter GUI run in Google Colab?

The native graphical Tkinter window normally needs a local desktop display. Use a local Python environment for this GUI example.

Related Tkinter tutorials

Continue with Tkinter Button options and commands, Entry widgets, Combobox widgets, Text widgets, Checkbutton selection, and Radiobutton values.

Dynamic Buttons handling » ON / OFF switch using Button images » Python Dictionary tutorial »

Back to top 🔝




Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer