title: Issues with Tkinter in having buttons in the secondary (second) window by click button in main window
body: <p>I have now been able to generate a code which pops up a new window with entries, when I click the button "Test" in the first Window. However, I am having problems creating buttons in the second window. The entries are created, but no buttons. Also as an additional question, I will like to add to this if it can be possible, that when I click the button Test in 1st window, the second window with entries/text/button pops up and the first window is killed? </p>
  
  <p><em>The way I have it now, it pops an error to me saying "'MySecondGUI' object has no attribute 'buttonPressed2"</em></p>
  
  <p>Help will be very much appreciated.  </p>
  
  <p>I have pasted my code below:</p>
  
  <p><strong>GUI_VIEW FILE ( gui_view.py)</strong></p>
  
  <pre><code>import tkinter as tk
  
  from tkinter import Tk
  
  
  class MyMainGUI(tk.Frame):
  
      def __init__(self, controller):
  
         tk.Frame.__init__(self)
         self.pack()
         self.controller = controller
  
         self.Button1=tk.Button(self)
         self.Button1["text"]= "Test"
         self.Button1["command"]=self.controller.buttonPressed1
         self.Button1.grid(row=2,column=0,rowspan=2)
  
  
  class MySecondGUI(tk.Toplevel):
  
         def __init__(self):
  
          tk.Toplevel.__init__(self)
  
  
          self.outputLabel2 = tk.Label(self)
          self.outputLabel2["text"] = ("Enter Value")
          self.outputLabel2.grid(row=5,rowspan=2)
  
          self.entrySpace2 = tk.Entry(self)
          self.entrySpace2.grid(row=8,column=0,rowspan=2)
  
          self.Button2=tk.Button(self)
          self.Button2["text"]= "Try Me"
          self.Button2["command"] = self.buttonPressed2
          self.Button2.grid(row=14,column=0,rowspan=2)enter code here
  </code></pre>
  
  <p><strong>GUI MAIN CONTROLLER FILE</strong></p>
  
  <pre><code>import tkinter as tk 
  
  import gui_view # the VIEW file
  
  
  class MainControl:
  
      def __init__(self):   
        self.root = tk.Tk()
        self.root.geometry('550x200')
        self.view = gui_view_temp.MyMainGUI(self)
        self.view.mainloop()
  
      def newWindow(self):
  
        self.viewNew = gui_view.MySecondGUI()
        self.viewNew.geometry('300x400')
        self.newDisplay = tk.Label(self.newWin, text='Test Mode')
        self.viewNew.mainloop()
        self.newDisplay.pack()
  
      def buttonPressed1(self):
  
           self.newWindow()
  
      def buttonPressed2(self):
  
           pass
  
  
  if __name__ == "__main__":
  
      c = MainControl()
  </code></pre>