输入正确的密码后无法关闭 Tkinter 的弹出窗口

Unable to close the popup for Tkinter after entering the correct password

输入正确的密码后无法关闭 Tkinter 的弹出窗口。输入正确的密码后,GUI 没有关闭。

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()

密码正确后需要调用root.destroy()

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()