title: Why withdraw() function is working only once in my python Tkinter code?
body: <p>I created several windows in Tkinter. I want to close them by button clicking and with this step open a new one. The problem is withdraw() function is working only at the first window. So, why the other windows are not closing?</p>
  <pre><code>from tkinter import *
  
  root = Tk()
  
  class window:
      def __init__(self, master):
          self.MyButton = Button(master, text='Go to 2th page', command=self.dunno)
          self.MyButton.pack()
  
      def dunno(self):
          self.goTo2th_page = Toplevel(root)
          root.withdraw()
          self.MyButton2 = Button(self.goTo2th_page, text='Go to 3th page', command=self.dunno2)
          self.MyButton2.pack()
  
      def dunno2(self):
          self.goTo3th_page = Toplevel(root)
          root.withdraw()
          self.MyButton3 = Button(self.goTo3th_page, text='Go to 4th page', command=self.dunno3)
          self.MyButton3.pack()
  
      def dunno3(self):
          self.goTo4th_page = Toplevel(root)
          root.withdraw()
          self.MyButton4 = Button(self.goTo4th_page, text='End', command=self.close)
          self.MyButton4.pack()
  
      def close(self):
          self.goTo4th_page.destroy()
  
  val = window(root)
  root.mainloop()
  </code></pre>