Pygame not showing anything in the window

和自甴很熟 提交于 2020-05-14 17:48:11

问题


Just started programming in python and pygames. Whenever I try running a py file with pygames, the pygames window will appear, but there will be absolutely nothing in it. No errors in the log, but nothing shows, it's just a gray screen. I tried running it on IDLE, and through the command line (I'm on a mac so I use the terminal)

And it's not just my programs that aren't showing anything, I've tried to run one of pygames examples, and it will still not display anything. For example, if I run the pygames alien example, the window will appear with a blank gray background. I'll hear the audio for the program, but no display.

Anything would help, I'm at a loss especially since no errors are showing in the log.

EDIT1: I'm using Python 3 (and I really need to keep using Python 3)

EDIT2: I'm using python 3.7. pygames version 1.9.4. The examples are with the pygames, they were downloaded together, so I assume it's for that version.

EDIT3: ok, my OS is Mojave 10.14. I've tried starting the application by: opening the file, running it on IDLE, and running it through the command line, none have worked. python2 is installed, but when I run the pygame it's a python3 file


回答1:


Known issue with Mojave - see their issue tracking: https://github.com/pygame/pygame/issues/555




回答2:


Try including a pygame.display.flip() call in the main loop.




回答3:


You can also install new pygame using pip install pygame=2.0.0.dev6. This worked in my case.



来源:https://stackoverflow.com/questions/53182886/pygame-not-showing-anything-in-the-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!