title: Clearing frames in tkinter
body: <p>Without any formal training and a very basic understanding of Python 3.3, I am trying really hard to understand tkinter to make a basic gui. I have read up on this method:</p>
  
  <p><a href="https://stackoverflow.com/questions/34301300/tkinter-understanding-how-to-switch-frames">Tkinter! Understanding how to switch frames</a></p>
  
  <p>which is way over my head. I don't learn very well from copying and pasting code. My question is this:</p>
  
  <p>If I want to make a gui with multiple windows, which I achieve by simply destroying a frame and replacing it with another while using a class, I guess I just don't understand why it's so darn difficult. I played around for a while today and I don't understand why the following code doesn't work. What I cannot wrap my noodle around is <strong>why does it flip to the new window properly, but fails to return to the main window.</strong> Both buttons are coded identically for their respective purposes, yet one works and one doesn't.</p>
  
  <pre><code>from tkinter import *
  
  class Application:
      def __init__(self, master):
          self.master = master
          self.new_switch_on = False
          self.main_switch_on = False
          self.main_frame()
  
      def main_frame(self):
          if self.new_switch_on == True:
              self.new_frame.destroy()
          self.new_switch_on = False
          self.main_switch_on = True
          self.main_frame = Frame(self.master, width = 200, height = 100)
          Label(self.main_frame, text = 'Main Frame').pack()
          Button(self.main_frame, text = 'Next', command = self.new_frame).pack()
          self.main_frame.pack()
  
      def new_frame(self):
          if self.main_switch_on == True:
              self.main_frame.destroy()
          self.main_switch_on = False
          self.new_switch_on = True
          self.new_frame = Frame(self.master, width = 400, height = 200)
          Label(self.new_frame, text = 'New Frame').pack()
          Button(self.new_frame, text = 'Back', command = self.main_frame).pack()
          self.new_frame.pack()
  
  root = Tk()
  root.geometry('-1+1')
  
  app = Application(root)
  
  root.mainloop()
  </code></pre>
  
  <p>I know I can follow the aforementioned link to get the desired result, but I just don't understand why something like this, or something else that is a bit more simplistic for a new learner couldn't accomplish the same result.</p>