title: Why isn't root.quit() or root.destroy() working but only the combination of both?
body: <p>In my program I implemented a Popup with some entries for user input. That Popup has an 'Enter' button to confirm and collect the input and then close the Popup automatically.
  For closing the Popup I found the <code>root.destroy()</code> and <code>root.quit()</code> methods (in my code self.master instead of root). I thought I kind of understand how to use them but apparently I didn't. :/</p>
  
  <pre class="lang-py prettyprint-override"><code>
  import tkinter as tk
  
  
  root = tk.Tk()
  window = MainWindow(root)
  root.mainloop()
  
  
  class MainWindow(tk.Frame):
  
      def __init__(self, master):
  
          tk.Frame.__init__(self, master)
          self.pack()
  
          #some irrelevant widgets
  
          btn_new_element = tk.Button(self, text='new', command=self.new_element)
          btn_new_element.pack()
  
  
      def new_element(self):
  
          root = tk.Toplevel()
          popup = Pupup(root, someData, otherData)
          root.mainloop()
  
          #do some other stuff
  
  
  
  class Popup(tk.Frame):
  
      def __init__(self, master, var1, var2):
  
          tk.Frame.__init__(self, master)
          self.pack()
  
          #some widgets
  
          btn = tk.Button(self, text='Enter', command=lambda a=var1, b=var2: self.foo(a, b))
          btn.pack()
  
  
      def foo(self, a, b):
  
          #do something with widget data
  
          self.master.quit()
          self.master.destroy()
  
  </code></pre>
  
  <p>In <code>foo()</code> first I only used <code>destroy()</code>. It closes the Popup but the program didnt continue with the code in <code>new_element()</code>. (It seemed as if the <code>mainloop()</code> was still looping.)
  Using <code>quit()</code> produced the opposite result: the rest of the code in <code>new_element()</code> was executed but the Popup was still there.
  Only using <code>quit()</code> and <code>destroy()</code> in that particular order gave me the result I wanted.</p>
  
  <p>According to thousands of examples on the internet it should be possible using only one of the two methods. Why isn't it working in my code?</p>
  
  <p>EDIT: deleted var1 and var2 from the MainWindow constructor (copy and paste mistake during creation of this question.</p>
  
  <p>EDIT: Also I get the feeling the the problem might be the scope of the root varibale. In <code>new_element()</code> do I create a local variable called root or do I overwrite the global root variable?</p>