title: I get the error _tkinter.TclError: bad window path name ".!button" and i'm not sure why
body: <p>I decided to try using classes to recreate a game so that I do not have to use global variables but when I try to run the game I'm getting an error.</p>
  
  <pre><code>Traceback (most recent call last):  File "D:\Users\James\Desktop\botmod OOP\index.py", line 203, in &lt;module&gt;    Game.New_Game(Root)  File "D:\Users\James\Desktop\botmod OOP\index.py", line 18, in New_Game    Play_Button = self.Start_Canvas.create_window(300, 325, window = Play_Button)  File "C:\Users\James\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py"&gt;, line 2501, in create_window    return self._create('window', args, kw)  File "C:\Users\James\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py"&gt;, line 2474, in _create    *(args + self._options(cnf, kw))))
  _tkinter.TclError: bad window path name ".!button"
  </code></pre>
  
  <p>I have looked through this to the best of my ability and cannot workout alone what the error is. Below is my code I can provide all the code if needed just comment. It should create a Tkinter button then apply it to the canvas but it gives me the error above.</p>
  
  <pre><code>def New_Game(self, Root):        
      self.Start_Canvas = Canvas(Root, width = 600, height = 500, bd=0, highlightthickness=0, bg = '#ffffff')
      self.Start_Canvas.pack()
  
      Title = self.Start_Canvas.create_text(300, 163, text = "BOTMOD", font = ('Cinema Gothic BTN Shadow', 75, 'normal'))
  
      Gen_PButton = Button(text = "PLAY", width = 10, font=('Arial', 15), command = self.Play_Game)
      Play_Button = self.Start_Canvas.create_window(300, 325, window = Gen_PButton)
  
      Gen_EButton = Button(text = "EXIT", width = 10, font=('Arial', 15), command = lambda: self.Game_End("EXIT"))
      Exit_Button = self.Start_Canvas.create_window(300, 375, window = Gen_EButton)
  </code></pre>
  
  <p>Before I used oop, this worked using Global variables and Functions so I cannot find what is causing the issue as the button is defined.</p>
  
  <p>The Example Code is Below</p>
  
  <pre><code>from tkinter import *
  from random import choice, shuffle
  
  class Game:
      def __init__(self):
          self.Playing_Game = True
          self.Game_Paused = False
          self.Restart_Game = False
          self.Already_Played = False
  
      def New_Game(self, Root):        
          self.Start_Canvas = Canvas(Root, width = 600, height = 500, bd=0, highlightthickness=0, bg = '#ffffff')
          self.Start_Canvas.pack()
  
          Title = self.Start_Canvas.create_text(300, 163, text = "BOTMOD", font = ('Cinema Gothic BTN Shadow', 75, 'normal'))
  
          Gen_PButton = Button(text = "PLAY", width = 10, font=('Arial', 15), command = self.Play_Game)
          Play_Button = self.Start_Canvas.create_window(300, 325, window = Gen_PButton)
  
          Gen_EButton = Button(text = "EXIT", width = 10, font=('Arial', 15), command = lambda: self.Game_End("EXIT"))
          Exit_Button = self.Start_Canvas.create_window(300, 375, window = Gen_EButton)
  
      def Play_Game(self):
          if self.Already_Played == False:
              self.Start_Canvas.destroy()
          self.Menu_Canvas = Canvas(Root, width = 600, height = 500, bd=0, highlightthickness=0, bg = '#C0C0C0')
          self.Menu_Canvas.pack()
  
      def Game_End(self):
          if self.End_Option == "EXIT":
              self.Playing_Game = False
              Root.destroy()
          else:
              self.Game_Finished = True
              self.Game_Canvas.create_rectangle(120, 120, 480, 300, fill = "#ffffff")
              self.Game_Canvas.create_text(300, 210, text = End_Option, font = ('Abadi', 35, "bold"))
              #Continue_Button = Button(Root, text = 'Continue', command = self.Game_Restart)
              Exit_Button = Button(Root, text = 'Exit', command = lambda: self.Game_End('EXIT'))
              #Continue_Button.pack()
              Exit_Button.pack()
  
  Root = Tk()
  Game = Game()
  
  while True:
      while Game.Restart_Game == False:
          if Game.Playing_Game == False:
              break
          else:
              Game_Finished = False
              Root = Tk()
              if Game.Already_Played == True:
                  Game.Play_Game()
                  Root.mainloop()
              elif Game.Already_Played == False:
                  Game.New_Game(Root)
                  Root.mainloop()
      break
  </code></pre>