fxfabre / 2048-AI

Artificial intelligence for the 2048 game
0 stars 0 forks source link

ValueError: id must be a valid identifier returned from after or after_idle #1

Open ghost opened 6 years ago

ghost commented 6 years ago

When I run python game.py I got the following error.

(2048_AI) D:\2048_AI>python game.py
Exception in Tkinter callback
Traceback (most recent call last):
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 746, in callit
    func(*args)
  File "D:\2048_AI\GUI\game2048_grid.py", line 536, in pop_tile
    _tile.animate_show()
  File "D:\2048_AI\GUI\game2048_grid.py", line 676, in animate_show
    interval=50, sequence=(6/5, 6/5, 5/6, 5/6),
  File "D:\2048_AI\GUI\game_grid.py", line 514, in start
    return self.run_sequencer( dict(interval=interval, step=step, sequence=sequence) )
  File "D:\2048_AI\GUI\game_grid.py", line 470, in run_sequencer
    self.stop()
  File "D:\2048_AI\GUI\game_grid.py", line 537, in stop
    self.after_cancel(self.__pid)
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 769, in after_cancel
    raise ValueError('id must be a valid identifier returned from '
ValueError: id must be a valid identifier returned from after or after_idle
Exception in Tkinter callback
Traceback (most recent call last):
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 746, in callit
    func(*args)
  File "D:\2048_AI\GUI\game2048_grid.py", line 536, in pop_tile
    _tile.animate_show()
  File "D:\2048_AI\GUI\game2048_grid.py", line 676, in animate_show
    interval=50, sequence=(6/5, 6/5, 5/6, 5/6),
  File "D:\2048_AI\GUI\game_grid.py", line 514, in start
    return self.run_sequencer( dict(interval=interval, step=step, sequence=sequence) )
  File "D:\2048_AI\GUI\game_grid.py", line 470, in run_sequencer
    self.stop()
  File "D:\2048_AI\GUI\game_grid.py", line 537, in stop
    self.after_cancel(self.__pid)
  File "D:\Miniconda3\envs\2048_AI\lib\tkinter\__init__.py", line 769, in after_cancel
    raise ValueError('id must be a valid identifier returned from '
ValueError: id must be a valid identifier returned from after or after_idle
ghost commented 6 years ago

It can be fixed by using the following code on game_grid.py at line 532:

# specific pid to cancel?
        if pid:
            try:
                self.after_cancel(pid)
            except ValueError:
                pass
        # internal pid
        else:
            try:
                self.after_cancel(self.__pid)
            except ValueError:
                pass
            self.__pid = 0