0

I'm trying to run a very basic pygame application, however I cannot get it to draw content to, or even fill the screen. I do update the screen in the main loop after filling it, however the screen stays blank and does not color black.

Printing inside the run function prints 60 times every second as expected. I do run MacOS Catalina which may be the problem, although I did not find any other mention of this problem.

import pygame

BLACK = (0, 0, 0)
WHITE = (255, 255, 255)

class Simulator:

    running = True

    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((800, 600), 0, 32)
        self.clock = pygame.time.Clock()
        pygame.display.set_caption('Traffic Simulator')


    def run(self):
        while (self.running):
            for e in pygame.event.get():
                if (e.type == pygame.QUIT):
                    self.running = False

            self.screen.fill(BLACK)

            pygame.display.flip()
            pygame.display.update()
            self.clock.tick(60)

if __name__ == "__main__":
    sim = Simulator()    
    sim.run()
    pygame.quit()

It shows a window with the title 'Traffic Simulator' with the default system color grey in the window, which I expect to be black.

sloth
  • 99,095
  • 21
  • 171
  • 219
JuNijland
  • 305
  • 1
  • 10
  • Yes, MacOS is always the problem. See https://stackoverflow.com/questions/52718921/problems-getting-pygame-to-show-anything-but-a-blank-screen-on-macos-mojave and a dozen other questions. – sloth Oct 14 '19 at 10:34

1 Answers1

1

@sloth Was right after all. After building pygame manually instead of pulling it from pip, it worked.

Here are the instructions I followed. https://www.pygame.org/wiki/MacCompile

JuNijland
  • 305
  • 1
  • 10
  • Feel free to add the steps you took to your answer and mark it as accepted. It will be helpfull for others. Questions with problems with MacOS pop up here from time to time and it would be nice to have a better question/answer than the one I linked above. – sloth Oct 14 '19 at 11:38
  • This solution worked for me as well, on Catalina 10.15.3, with Python 3.8.2. – lorg Mar 14 '20 at 18:54