问题描述
我一直在玩 python 龟,但我似乎无法让 exitonclick 函数工作,每当我单击窗口试图关闭屏幕时,它都会返回错误。我也尝试删除 mainloop,这会删除错误消息但也不会关闭窗口。
我的代码如下:
import turtle
wn = turtle.Screen()
circle1 = turtle.Turtle(shape = 'circle')
circle1.fd(100)
wn.exitonclick()
wn.mainloop()
错误信息是:
Traceback (most recent call last):
File "/Users/luke/test.py",line 11,in <module>
wn.mainloop()
File "/Users/luke/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/turtle.py",line 813,in mainloop
TK.mainloop()
File "/Users/luke/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py",line 560,in mainloop
_default_root.tk.mainloop(n)
AttributeError: 'nonetype' object has no attribute 'tk'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)