title: Hide the root window when a Toplevel window is opened and make it reappear when the Toplevel is destroyed
body: <p>How can I hide the MAIN window when the SECOND window is opened and then make the MAIN window reappear when the SECOND window is closed?</p>
  
  <p>I understand the use of withdraw() and deiconify() but not sure how to apply them in this situation.</p>
  
  <p>The reason for this would be to eventually create a program which the MAIN window acts as a menu which hides when other windows are opened from it and reappears when these other windows are exit.</p>
  
  <pre><code>from tkinter import *
  
  class Main():
  
      def __init__(self, master):
          self.master = master
          self.title = "Main Window"
  
          self.button1 = Button(self.master, text="Click Me", command = self.Open)
          self.button1.grid(row=0, column=0, sticky=W)
          self.button2 = Button(self.master, text="Close", command = self.Close)
          self.button2.grid(row=1, column=0, sticky=W)
  
  
      def Open(self):
          second_window = Toplevel(self.master)
          window2 = Second(second_window)
  
      def Close(self):
          self.master.destroy()
  
  
  class Second():
  
      def __init__(self, master):
          self.master = master
          self.title = "Second Window"
  
  
  
  root = Tk()
  main_window = Main(root)
  root.mainloop()
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>