_tkinter.TclError: invalid command name ".54600176" error, what is going on?
Question: I am new to python and am trying to code a simple game, but am continuously
receiving this error message after updating the main game loop.

    
    
     Traceback (most recent call last):
      File "D:\python shell\Bubble Blaster.py", line 75, in <module>
        move_bubbles()
      File "D:\python shell\Bubble Blaster.py", line 67, in move_bubbles
        c.move(bub_id[i], -bub_speed[i], 0)
      File **not displaying for privacy**
    \lib\tkinter\__init__.py", line 2430, in move
        self.tk.call((self._w, 'move') + args)
    _tkinter.TclError: invalid command name ".54600176"
    

the lines which apparently have an error are this one:

    
    
    #MAIN GAME LOOP
    while True:
        if randint(1, BUB_CHANCE) == 1:
            create_bubble()
        move_bubbles()
        window.update()
        sleep(0.01) 
    

move_bubbles() is line 75

and this:

    
    
    def move_bubbles():
        for i in range(len(bub_id)):
            c.move(bub_id[i], -bub_speed[i], 0)
    

def move_bubbles(): is line 67

So far the 'bubbles' I created do as they are supposed to, but when I tried to
create a collision event that causes the bubbles to 'pop' when they hit the
submarine controller I created, I get this error message. I have checked every
line of code and compared it to the tutorial book I am using and I haven't
made an error, can someone please help me or explain what the error means? It
is a very frustrating issue!


Answer: In Tk the root window is named '.' (dot) and its children are named as a dot
delimited path of parent names. Tkinter generates the names for you using
numbers. The other thing to note is that in Tk the name of a window is also a
command that provides operations on that window. So the error you have here is
telling you that one of your windows no longer exists as the command that
manages it is gone. I suggest that your `bub_id` list is being modified while
you iterate over it leaving you with the potential to obtain a window name
that has been destroyed elsewhere. You can avoid the error using
`c.winfo_exists` which lets you know if the window is actually existing and
works even if the window has been destroyed. But really you should try to
avoid making calls on destroyed windows.

Here's a small example that produces the same error:

    
    
    >>> import tkinter as tk
    >>> main = tk.Tk()
    >>> b = tk.Label(main, text="hello")
    >>> b.destroy()
    >>> b.configure()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.4/tkinter/__init__.py", line 1322, in configure
        return self._configure('configure', cnf, kw)
      File "/usr/lib/python3.4/tkinter/__init__.py", line 1310, in _configure
        return self._getconfigure(_flatten((self._w, cmd)))
      File "/usr/lib/python3.4/tkinter/__init__.py", line 1294, in _getconfigure
        for x in self.tk.splitlist(self.tk.call(*args)):
    _tkinter.TclError: invalid command name ".140685140686048"
    >>> b.winfo_exists()
    0
    >>> 
    

