Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in Tkinter callback when quit life game #98

Open
liudonghua123 opened this issue May 23, 2023 · 2 comments
Open

Exception in Tkinter callback when quit life game #98

liudonghua123 opened this issue May 23, 2023 · 2 comments

Comments

@liudonghua123
Copy link

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
Copy link
Author

The exception comes from the following code.

def draw():
"""Draw all the squares."""
step()
clear()
for (x, y), alive in cells.items():
color = 'green' if alive else 'black'
square(x, y, 10, color)
update()
ontimer(draw, 100)

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
Copy link

tradexy commented Apr 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants