tkinter clear selected item code example
Example 1: tkinter clear entry
widget.delete(0, END)
Example 2: python tkinter clear entry
# Clear an entry widget on button press
from tkinter import *
root = Tk()
def clearEntryInput():
entry.delete(0, END)
entry = Entry(root, width=30) # You must .pack() or .grid() on the next line
entry.pack()
Button(root, text="Clear", command=clearEntryInput).pack()
root.mainloop()
# This is the error you get if you .pack() or .grid() on the same line:
# AttributeError: 'NoneType' object has no attribute 'delete'
# https://stackoverflow.com/questions/13002843/attributeerror-nonetype-object-has-no-attribute-delete