简体   繁体   English

在Canopy中运行Python Turtle的问题

[英]Issue running Python turtle in Canopy

I wrote this code: 我写了这段代码:

import turtle
wn = turtle.Screen()
Matthew = turtle.Turtle() 
Matthew.forward(200)
Matthew.left(90)
Matthew.forward(200) 

and saved it as Matthew.py If I run Matthew.py using Idle I get the expected behaviour (new window opens and little turtle does its moves). 并将其保存为Matthew.py。如果我使用Idle运行Matthew.py,则会得到预期的行为(新窗口打开,小乌龟开始移动)。 If I open and run Matthew.py in Canopy it just hangs there. 如果我在Canopy中打开并运行Matthew.py,它就会挂在那里。 All I see is: 我所看到的是:

%run /Users/matteoniccoli/Canopy/Notebooks/Matthew.py

but it just hangs there, no errors. 但它只是挂在那里,没有错误。

Am I doing something wrong? 难道我做错了什么?

Please notice as an experiment I copied the same code in a IPython notebook and saved it as Matthew.ipynb, then run the code in the notebook in Canopy and it works fine. 请注意,作为实验,我在IPython笔记本中复制了相同的代码,并将其保存为Matthew.ipynb,然后在Canopy中的笔记本中运行该代码,效果很好。

By default Canopy Python uses a Qt GUI backend. 默认情况下,Canopy Python使用Qt GUI后端。 Turtle uses a TK backend. Turtle使用TK后端。 They conflict. 他们发生冲突。 See https://support.enthought.com/entries/21793229-Using-Tkinter-Turtle-in-Canopy-s-IPython-panel for resolution. 有关解析,请参见https://support.enthought.com/entries/21793229-Using-Tkinter-Turtle-in-Canopy-s-IPython-panel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM