tkinter.Entry.destroy


Definition
The Entry.destroy the Entry text box.

Syntax
tkinter.Entry.destroy
Entry.destroy

Examples
Entry().Destroy
The Entry.get() input text verified through Button(command).
from tkinter import*

master=Tk()
master.title("Login")

def validate1():
    if  entry.get()=="pythonlake":
        label1=Label(master, text="Welcome")
        label1.grid(row=0,column=3)
        entry.destroy()
        button.destroy()
        label.destroy()
    else:
        label2=Label(master, text="You are not authorized", background="red", fg="white")
        label2.grid(row=0,column=3)

label=Label(master, text="Enter your username: ")
label.grid(row=0,column=0)
           
entry=Entry(master)
entry.grid(row=0,column=1)

button=Button(master, text="Submit",command=validate1)
button.grid(row=0,column=2)

master.mainloop()









The method  Erase text, delete Entry, and destroy the widget() through Button(command) through default pack() setting.
from tkinter import*

master=Tk()

def e1_delete():
    e1.delete(first=0,last=100)

def master_destroy():
     master.destroy()
    

def entry_destroy():
    e1.destroy()
    

e1=Entry(master, width=35)
e1.pack()


b_erase=Button(master, text="Erase", command=e1_delete)
b_erase.pack()

b_quit_destroy=Button(master, text="Quit", command=master_destroy)
b_quit_destroy.pack()


b_delete_text=Button(master, text="Delete Entry", command=entry_destroy)
b_delete_text.pack()


master.mainloop()


 






Comments