1# Clear an entry widget on button press
2from tkinter import *
3
4root = Tk()
5
6def clearEntryInput():
7 entry.delete(0, END)
8
9entry = Entry(root, width=30) # You must .pack() or .grid() on the next line
10entry.pack()
11
12Button(root, text="Clear", command=clearEntryInput).pack()
13
14root.mainloop()
15
16# This is the error you get if you .pack() or .grid() on the same line:
17# AttributeError: 'NoneType' object has no attribute 'delete'
18# https://stackoverflow.com/questions/13002843/attributeerror-nonetype-object-has-no-attribute-delete