当我从 IDLE 运行后尝试退出时,pygame 冻结了!
我通过 livewires 包装器运行它,它只是 pygame 和其他 python 模块的训练轮;但每次我运行它时,它都会执行,当我尝试退出时,它不会响应然后崩溃。
任何关于我如何解决这个问题的意见都会很棒。我的教科书中没有任何输入,所有谷歌似乎都使用 pygame 本身产生了这个问题的结果。
显然 pygame 和 Tkinter 似乎有冲突?
提前致谢!
附录-这是我试图运行的代码:
from livewires import games
screen_w = 640
screen_h = 480
my_screen = games.Screen (wid, heit)
my_screen.mainloop()
I'm running it through the livewires wrapper which is just training wheels for pygame and other python modules in general; but everytime I run it, it'll execute and when I try to exit, it will not respond and then crash.
Any input on how I could go about fixing this would be great. There isn't any input in my textbook and all google seems to yield are results to this problem using pygame itself.
Apparently pygame and Tkinter seem to conflict?
Thanks in advance!
Addendum - This is the code I was trying to run:
from livewires import games
screen_w = 640
screen_h = 480
my_screen = games.Screen (wid, heit)
my_screen.mainloop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
类似的问题: Pygame 屏幕在我关闭时冻结
这些结果可能解决了您遇到的相同问题。这是来自 livewires 的 games.py 文件的相关部分,它在任何地方都不会调用 pygame.quit() :
QUIT 事件只是设置一个标志,使您脱离
中的 while 循环代码>主循环函数。我猜测,如果您在 Python 目录中找到此文件,并在
mainloop
的最后一行后面添加pygame.quit()
,它就会解决您的问题。Similar question: Pygame screen freezes when I close it
Those results probably address the same problem you're having. This is the relevant part of the games.py file from livewires, and nowhere does it call
pygame.quit()
:The QUIT event just sets a flag which drops you out of the while loop in the
mainloop
function. I'm guessing that if you find this file in your Python directory and stick apygame.quit()
after the last line inmainloop
, it will solve your problem.我同意。你需要将整个程序(要执行的部分,而不是定义等)放入 while 循环中。问题是,在 IDLE 中退出时,pygame 不会被告知关闭,但在 IDLE 之外,程序的关闭会覆盖需要关闭pygame。
这是循环:
I agree. you need to put the whole program (the part to be executed, not the definitions and such) into a while loop.The problem is that pygame is not told to close when exited in IDLE, but outside of IDLE the closure of the program overrides the need to close pygame.
here is the loop: