title: Removing and recreating a tkinter window with a restart button
body: <p>I have this code for a game where you have to click the mosquito in time. If you don't, you lose and can restart by clicking the Restart Button. But when I get to that point, the window just closes and re-opens and I can't click anything. How can I fix it? (Note: I am new to Python)</p>
  
  <pre><code>from tkinter import *
  from random import randint
  from time import *
  
  
  def replace():
      global score
      global initialized
      global start
      end = time()
      timeneeded = end - start
      label.config(text="")
      if timeneeded &gt; (2-score/20) and initialized &gt; 0:
          lose()
      else:
          z1=randint(0,950)
          z2=randint(0,660)
          button.place(x=z1,y=z2)
          start = time()
          initialized = 1
          score=score+1
  
  def lose():
      text="Diesmal hast Du zu lange gebraucht!\n"
      text+="Du hast insgesamt "+str(score)+" Mücken erwischt!"
      label.config(text=text)
      label.pack(side=LEFT,anchor=CENTER,fill=BOTH)
      restartButton=Button(window, text = "Nochmal?", command = restart())
      restartButton.place(x=700, y=350)
  
  def restart():
      global start
      global score
      global initialized
      global mosquito
      global z1
      global z2
      global button
      global label
      global window
  
      try:
          if('normal' == window.state()):
              window.destroy()
      finally:
          score = 0
          initialized = 0
          start=time()
          window =Tk()
          # mosquito=PhotoImage(file="/home/pi/Downloads/mosq45.png")
          mosquito=PhotoImage(file="C:/Users/Julian/Downloads/mosq45.png")
          z1=350
          z2=350
          initialized = 0
          start=time()
          score = 0
          window.title("Fang die Mücke!")
          window.geometry("1020x740")
          button=Button(window,image=mosquito,command=replace)
          button.place(x=z1,y=z2)
          label=Label(window,font=("Arial",32),text="Fang so viele Mücken wie möglich!")
          label.place(x=10,y=200)
          window.mainloop()
  
  
  
  window =Tk()
  # mosquito=PhotoImage(file="/home/pi/Downloads/mosq45.png")
  mosquito=PhotoImage(file="C:/Users/Julian/Downloads/mosq45.png")
  z1=350
  z2=350
  initialized = 0
  start=time()
  score = 0
  window.title("Fang die Mücke!")
  window.geometry("1020x740")
  button=Button(window,image=mosquito,command=replace)
  button.place(x=z1,y=z2)
  label=Label(window,font=("Arial",32),text="Fang so viele Mücken wie möglich!")
  label.place(x=10,y=200)
  window.mainloop()
  </code></pre>