title: Why does my window reopen when closed?
body: <p>I was testing my friend's <code>Tkinter</code> code, and came across this bizarre behaviour.</p>
  
  <p>When I use the Windows 'X' button (top-right of window) to close this Tk window (class/method?), it closes, then reopens a second afterwards. A second click of the 'X' button finally closes the window.
  Here's the code for the window (assume that all button commands are defined):</p>
  
  <pre><code>from tkinter import *
  import os, string, random
  
  def generate():
      length = 13
      chars = string.ascii_letters + string.digits + '!@#$%^&amp;*()'
      random.seed = (os.urandom(1024))
      master = Tk()
      master.title("Secure Password Generator")
      master.geometry("310x24")
      master.maxsize(310,24)
      master.minsize(310,24)
      text = Text(master)
      ranPass = ''
      for i in range(length):
          ranPass += random.choice(chars)
      text.insert(INSERT,"Your secure password is %s." % ranPass)
      text.config(state=DISABLED)
      text.pack()
  
  root = Tk()
  root.title ("Sleak Test")
  root.geometry("100x500")
  app = Frame(root)
  app.grid()
  button5 = Button(app)
  button5.grid()
  button5.configure(text = "Password Generator", fg='green', bg='black', command=generate)
  root.mainloop()
  try:
      root.destroy()
  except tkinter.TclError:
      pass
  </code></pre>
  
  <p>Is there a reason that I would have to click the close button on the window <em>twice</em>?</p>
  
  <p>EDIT: Made the example actually work. Sorry guys!
  <br>SECOND EDIT: Ok, this is strange. This works perfectly, which means there must be something wrong with the code elsewhere. This just got strange.</p>