Tkinter Entry delete() Method
In the tkinter module application you can use the delete(first,last=None) method to delete the string within the Entry from the first character to the last-1 character, if you want to delete the whole string you can use delete(0,END).
Tkinter Entry delete() Method Example#1
When the Login button is clicked, the contents of the text box Entry are cleared.
from tkinter import *
def printInfo():
print("Account:%s\nPassword: %s" %(accountE.get(),pwdE.get()))
accountE.delete(0,END)
pwdE.delete(0,END)
root = Tk()
root.title("apidemos.com")
msg = "Welcome to apidemos.com"
myPic = PhotoImage(file="apidemos.png")
logo = Label(root,image=myPic,text=msg,compound=BOTTOM)
accountL = Label(root,text="Account")
accountL.grid(row=1)
pwdL = Label(root,text="Password")
pwdL.grid(row=2)
logo.grid(row=0,column=0,columnspan=2,pady=10,padx=10)
accountE = Entry(root)
pwdE = Entry(root,show="*")
accountE.insert(0,"kevin")
pwdE.insert(0,"pwd")
accountE.grid(row=1,column=1)
pwdE.grid(row=2,column=1,pady=10)
# The following Login and Quit buttons are created
loginbtn = Button(root,text="Login",command=printInfo)
loginbtn.grid(row=3,column=0,sticky=W,pady=5)
quitbtn = Button(root,text="Quit",command=root.quit)
quitbtn.grid(row=3,column=1,sticky=W,pady=5)
root.mainloop()
Output: