How to allow a tkinter window to be opened multiple times
<p>I am making a makeshift sign in system with python. Currently if you enter the correct password it brings up a new admin window. If you enter the wrong one it brings up a new window that says wrong password. If you exit out of one of those windows and then try to enter a password again it breaks. <code>tkinter.TclError: can't invoke "wm" command: application has been destroyed</code> Is there a way to prevent this so if someone enters the wrong password they don't need to restart the app?    </p>

<pre><code>import tkinter
from tkinter import *

#define root window
root = tkinter.Tk()
root.minsize(width=800, height = 600)
root.maxsize(width=800, height = 600)

#define admin window
admin = tkinter.Tk()
admin.minsize(width=800, height = 600)
admin.maxsize(width=800, height = 600)
admin.withdraw()

#define wrong window
wrong = tkinter.Tk()
wrong.minsize(width=200, height = 100)
wrong.maxsize(width=200, height = 100)
wrong.withdraw()
Label(wrong, text="Sorry that password is incorrect!", font=("Arial", 24), anchor=W, wraplength=180, fg="red").pack()

#Admin sign in Label
areAdmin = Label(root, text="Administrator sign in", font=("Arial", 18))
areAdmin.pack()

#password label and password
passwordLabel = Label(root, text="Password: ", font=("Arial", 12))
passwordLabel.place(x=300, y=30)

#password entry
adminPasswordEntry = Entry(root)
adminPasswordEntry.place(x=385, y=32.5)

#function for button
def getEnteredPassword():
    enteredPassword = adminPasswordEntry.get()
    if enteredPassword == password:
        admin.deiconify()
    else:
        wrong.deiconify()

#enter button for password
passwordEnterButton = Button(root, text="Enter", width=20, command=getEnteredPassword)
passwordEnterButton.place(x=335, y=60)


mainloop()
</code></pre>

<p>I don't know <code>tkinter</code> much but I could fix your code, I hope it's a proper fix.</p>

<ol>
<li>Create <code>Toplevel</code> windows not <code>Tk</code>. those are dialog windows, as opposed to <code>Tk</code> window which must be unique. Same look &amp; feel, same methods</li>
<li>Create windows when needed, and each time. Else, closing them using the close gadget destroys them.</li>
</ol>

<p>Fixed code, enter wrong or good password as many times you want without crash:</p>

<pre><code>import tkinter
from tkinter import *

password="good"

#define root window
root = tkinter.Tk()
root.minsize(width=800, height = 600)
root.maxsize(width=800, height = 600)



#Admin sign in Label
areAdmin = Label(root, text="Administrator sign in", font=("Arial", 18))
areAdmin.pack()

#password label and password
passwordLabel = Label(root, text="Password: ", font=("Arial", 12))
passwordLabel.place(x=300, y=30)

#password entry
adminPasswordEntry = Entry(root)
adminPasswordEntry.place(x=385, y=32.5)

#function for button
def getEnteredPassword():
    enteredPassword = adminPasswordEntry.get()
    if enteredPassword == password:
        admin = tkinter.Toplevel()
        admin.minsize(width=800, height = 600)
        admin.maxsize(width=800, height = 600)
        #admin.withdraw()
    else:
        wrong = tkinter.Toplevel()
        wrong.minsize(width=200, height = 100)
        wrong.maxsize(width=200, height = 100)
        Label(wrong, text="Sorry that password is incorrect!", font=("Arial", 24), anchor=W, wraplength=180, fg="red").pack()


#enter button for password
passwordEnterButton = Button(root, text="Enter", width=20, command=getEnteredPassword)
passwordEnterButton.place(x=335, y=60)


mainloop()
</code></pre>

python tkinter