Python 在 Mac 上崩溃
我只是下载了一个图形模块(位于 http://mcsp.wartburg.edu/zelle/python/< /a>)并编写了一个快速程序来测试它。它应该做的就是创建一个窗口。它可以工作,但是创建窗口的第二个Python(不是IDLE)变得无响应,我必须强制退出。可能是什么原因造成的?代码(他们作为示例提供)是:
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse()
win.close()
单击后它突然崩溃。
I just download a graphics module (found at http://mcsp.wartburg.edu/zelle/python/) and wrote a quick program to test it out. All it is supposed to do is create a window. It works, but the second the window is created Python (not IDLE) goes non-responsive and I have to force quit. What could be causing this? The code (that they provide as an example) is:
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse()
win.close()
After I click it suddenly crashes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上是预期的行为。该线
会挂起解释器和窗口,直到您单击为止。单击后,该行
会销毁窗口,然后您的程序终止。这对您来说可能看起来是“崩溃”,但实际上是 Python 程序运行的预期结束。 (如果您遇到错误,请在您的问题中发布跟踪。)
This is actually expected behavior. The line
hangs the interpreter and window until you click. After the click, the line
destroys the window, then your program terminates. This may appear as a "crash" to you, but is actually the expected end of your Python program's run. (If you're getting an error, post the trace in your question.)