为什么使用turtle模块后ActivePython会冻结?
我已经安装了 ActivePython 3.1 并根据文档中的turtle模块的要求使用 -n
参数运行IDLE。但是,当我尝试将它与诸如 turtle.postion()
之类的调用一起使用时,会打开新窗口(带有 Tk 图标),该窗口会冻结并且不显示任何内容。 可能出什么问题了?
I've installed ActivePython 3.1 and ran IDLE with -n
parameter as required by the turtle module in documentation. However when I try to use it with call such as turtle.postion()
, new windows is opened (with Tk icon), which freezes and shows nothing.
What could be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
冻结的直接原因是 Tk 事件循环没有得到服务。如果没有这个,Tk 窗口就无法正确显示或更新(所有 GUI 工具包都是基于事件的,但 Tk 尤其如此)。不幸的是,我对 Python 的 Tk 绑定或 IDLE 不太了解,无法说出这是由什么引起的。
The immediate cause of the freeze is that the Tk event loop is not being serviced. Without that, Tk windows do not display or update correctly (all GUI toolkits are event based, but Tk is particularly so). Unfortunately, I don't know Python's Tk binding or IDLE nearly well enough to be able to say what that is caused by.
通过不在 IDLE 中运行它来部分解决,我将它作为 python 脚本执行并等待输入以查看绘制的内容。
Partially resolved by not running it in IDLE, I execute it as a python script and wait for input to see what is drawn.