Unable to close the popup for Tkinter after entering the correct password. After entering the correct password the GUI is not closing.
from tkinter import *
root = Tk()
e = Entry(root, width=50)
e.pack()
def myClick():
password = "sunny567"
get = e.get()
if get == password:
myLabel = Label(root, text=get)
myLabel.pack()
else:
myLabel = Label(root, text="Entered Password is wrong. Please try again.")
myLabel.pack()
myButton = Button(root, text="Enter the password", command=myClick)
myButton.pack()
root.mainloop()
You need to call root.destroy()
when password is correct.
from tkinter import *
root = Tk()
e = Entry(root, width=50)
e.pack()
def myClick():
password = "sunny567"
get = e.get()
if get == password:
root.destroy() # close the root window
else:
myLabel.config(text="Entered Password is wrong. Please try again.")
myButton = Button(root, text="Enter the password", command=myClick)
myButton.pack()
myLabel = Label(root)
myLabel.pack()
root.mainloop()