title: Why am I receiving a error when trying to use tkinter to make multiple windows?
body: <p>I bolded the parts where I think the problem occurs.
  When run, the program stops and does not do anything but continues to run.
  This is a part of a bigger project to try to code minesweeper.
  I put ###HERE### on places where the problem occurs.
  ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎ ‏‏‎ ‎‏‏‎ ‎ ‏‏‎ ‎</p>
  <pre><code>from tkinter import *
  from tkinter import Canvas
  from PIL import ImageTk, Image
  from time import sleep
  
  
  class ResizingCanvas(Canvas):
      def __init__(self,parent,**kwargs):
          Canvas.__init__(self,parent,**kwargs)
          self.bind(&quot;&lt;Configure&gt;&quot;, self.on_resize)
          self.height = self.winfo_reqheight()
          self.width = self.winfo_reqwidth()
  
      def on_resize(self,event):
          # determine the ratio of old width/height to new width/height
          wscale = float(event.width)/self.width
          hscale = float(event.height)/self.height
          self.width = event.width
          self.height = event.height
          # resize the canvas
          self.config(width=self.width, height=self.height)
          # rescale all the objects tagged with the &quot;all&quot; tag
          self.scale(&quot;all&quot;,0,0,wscale,hscale)
  
  
  class Minesweeper(Tk):
  
      def __init__(self, master):
          Tk.__init__(self)
          fr = Frame(self)
          fr.pack(fill=BOTH, expand=YES)
          self.canvas = ResizingCanvas(fr, width=940, height=920, bg=&quot;black&quot;, highlightthickness=0)
          self.canvas.pack(fill=BOTH, expand=YES)
          self.count = 0
          self.start = 0
          self.newWindow = Toplevel(self.master) ####HERE###
          self.app = Control(self.newWindow)     ####HERE###
          self.title(&quot;MineSweeper&quot;)
          x1 = 20
          y1 = 20
          x2 = 80
          y2 = 80
          self.block_pic = PhotoImage(file='C:/Users/akiva/OneDrive/Desktop/block.PNG')
          self.flag_pic = PhotoImage(file='C:/Users/akiva/OneDrive/Desktop/flag.PNG')
          for k in range(14):
              for i in range(15):
                  self.canvas.create_rectangle(x1, y1, x2, y2, fill='white')
                  x1 += 60
                  x2 += 60
              x1 = 20
              x2 = 80
              y1 += 60
              y2 += 60
  
      def shift_image(self):
          if self.count == 0:
              Tk.canvas.itemconfig(self.block_pic, image=self.flag_pic)
  
      def end(self):
          del self.block_pic
          print(&quot;Game has ended&quot;)
          self.after(2000, quit())
          print(&quot;Game has ended&quot;)
          self.start = 0
  
      def frame(self):
          self.start += 1
          if self.start == 1:
              x1 = 50
              y1 = 50
              for i in range(14):
                  for k in range(15):
                      self.canvas.create_image(x1, y1, image=self.block_pic)
                      x1 += 60
                  x1 = 50
                  y1 += 60
              self.canvas.pack()
          else:
              print(&quot;Game has already started&quot;)
  
  
  class Control:
      def __init__(self, master):
          self.master = master
          self.frame = Frame(self.master)
          **start_button = Button(self.frame, text=&quot;Start Game&quot;, command=Minesweeper(Tk).frame(),)  ####HERE###
          stop_button = Button(self.frame, text=&quot;End Game&quot;, command=Minesweeper(Tk).end())     ####HERE###
          start_button.pack()
          stop_button.pack()
          self.quitButton = Button(self.frame, text='Quit', width=25, command=self.close_windows)
          self.quitButton.pack()
          self.frame.pack()
  
      def close_windows(self):
          self.master.destroy()
  
  
  
  
  
  
  
  if __name__ == &quot;__main__&quot;:
      root = Tk
      window = Minesweeper(root)
      root.mainloop()
  
  </code></pre>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 107, in &lt;module&gt;
      window = Minesweeper(root)
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 37, in __init__
      self.app = Control(self.newWindow)
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 86, in __init__
      start_button = Button(self.frame, text=&quot;Start Game&quot;, command=Minesweeper(Tk).frame(),)
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 37, in __init__
      self.app = Control(self.newWindow)
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 86, in __init__
      start_button = Button(self.frame, text=&quot;Start Game&quot;, command=Minesweeper(Tk).frame(),)
    File &quot;C:/Users/akiva/PycharmProjects/helloOpencv/Mine_sweeper.py&quot;, line 29, in __init__
      Tk.__init__(self)
  </code></pre>