title: I am getting KeyError: <class '__main__. in tkinter while trying to raise another frame?
body: <p>I am getting this error -</p>
  
  <pre><code>KeyError: &lt;class '__main__.PublishPage'&gt;
  </code></pre>
  
  <p>This is my code -</p>
  
  <pre><code>p = 0
  #Now, Adding the different pages for the game
  class HeadlineGame(tk.Tk):
      def __init__(self, *args, **kwargs):
          tk.Tk.__init__(self, *args, **kwargs)
          container = tk.Frame(self)
          container.pack(side="top", fill="both", expand=True)
  
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          self.frames = {}
  
          frame = StartPage(container, self)
          self.frames[StartPage] = frame
  
          frame.grid(row=0, column=0, sticky="nsew")
          self.show_frame(StartPage)
  
      def show_frame(self, controller):
          frame = self.frames[controller]
          frame.tkraise()
  
  class StartPage(tk.Frame):
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent)
          publishbutton = tk.Button(self, image=publishimg, borderwidth=0, command= lambda: controller.show_frame(PublishPage))
          publishbutton.image = publishimg
          publishbutton.place(x=503, y=315)
  
  class PublishPage(tk.Frame):
          def __init__(self, parent, controller):
           button2 = tk.Button(self, text="Test")
           button2.grid(row=0, column=0)
  
  
  
  app = HeadlineGame()
  app.geometry('1366x768')
  app.mainloop()
  </code></pre>
  
  <p>I have tried to resolve the issue but to no avail.
  Is this a problem with the lambda command? 
  I want it so that when I push the button, it takes me to the second frame, even if this specific issue cannot be resolved is there a way to achieve that?</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong> traceback error:</p>
  
  <pre><code>&gt; Exception in Tkinter callback Traceback (most recent call last):   File
  &gt; "C:\Users\DELL\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py",
  &gt; line 1883, in __call__
  &gt;     return self.func(*args)   File "C:\Users\DELL\Desktop\Python\intro.py", line 276, in &lt;lambda&gt;
  &gt;     publishbutton = tk.Button(self, image=publishimg, borderwidth=0, command= lambda: controller.show_frame(PublishPage))   File
  &gt; "C:\Users\DELL\Desktop\Python\intro.py", line 197, in show_frame
  &gt;     frame = self.frames[controller] KeyError: &lt;class '__main__.PublishPage'&gt;
  
  </code></pre>