grantjenks / free-python-games

Free Python Games
http://www.grantjenks.com/docs/freegames/
Other
3.5k stars 1.38k forks source link

Exception in Tkinter callback when quit life game #98

Open liudonghua123 opened 1 year ago

liudonghua123 commented 1 year ago

I tried to run the life game via freegames play life. When I click close button of the game window. I got Exception in Tkinter callback.

> freegames play life
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 861, in callit
    func(*args)
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\site-packages\freegames\life.py", line 61, in draw
    ontimer(draw, 100)
  File "<string>", line 5, in ontimer
turtle.Terminator
liudonghua123 commented 1 year ago

The exception comes from the following code.

https://github.com/grantjenks/free-python-games/blob/cfa331f3d2d20f3fb742c9cd5504cea53504b0ef/src/freegames/life.py#L53-L61

And I can catch and pass the exception to make it work.

See also https://hg.python.org/cpython/rev/a43d03cdf38b, https://python-forum.io/thread-25483.html.

tradexy commented 7 months ago

I am using miniconda in a macbook. I replicated the error. When I click the close button I got a similar Exception in Twinker Callback:

Traceback (most recent call last): File "/opt/miniconda3/envs/game_of_life/lib/python3.9/tkinter/__init__.py", line 1892, in __call__ return self.func(*args) File "/opt/miniconda3/envs/game_of_life/lib/python3.9/tkinter/__init__.py", line 814, in callit func(*args) File "/Users/johnmosquera/Documents/AI/yt-matthew-berman/pyGameExample/game_of_life.py", line 61, in draw ontimer(draw, 100) File "<string>", line 5, in ontimer turtle.Terminator