3

I've been trying to get Pygame to work for a while now. It runs without any issues, but nothing is shown on the screen. I did try to run the Pygame alien example game, it does not show up either - even though music starts playing

import pygame

pygame.init()

display_width = 800
display_height = 600

white = (0, 0, 0)

gameDisplay = pygame.display.set_mode((display_width, display_height))

pygame.display.set_caption("This is a game!")

clock = pygame.time.Clock()

running = True

while running is True:
    for event in pygame.event.get():
        if event.type is pygame.QUIT:
            running = False

    gameDisplay.fill(white)

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

In the above code I tried filling the screen with the color white, but the window is just blank (the default Mac OS colour)

EDIT: It seems like it is a problem with Mac OS Mojave

To clarify the code, I tried with red as well as black and white in the end, and nothing shows up

kaffeDiem
  • 41
  • 3
  • Seems to be the same like this one:* [Why the draw rectangle doesn't show in the screen?](https://stackoverflow.com/questions/54493449/why-the-draw-rectangle-doesnt-show-in-the-screen)* -still unanswered – Rabbid76 Feb 05 '19 at 16:20
  • There's been a LOT of OSX related Pygame issues the last couple of weeks. I suggest you submit a bug report on their site and link to these two questions. – Torxed Feb 05 '19 at 16:29
  • What behaviour are you expecting? The code you've provided just creates a window and fill it with a black color. Although, you named the black color to `white`. That might be what's causing the confusion. – Ted Klein Bergman Feb 05 '19 at 17:09
  • 3
    To elaborate; white is `(255, 255, 255)`, black is `(0, 0, 0)`. You've defined `white = (0, 0, 0)`. – Ted Klein Bergman Feb 05 '19 at 17:22
  • Have you installed Python with Homebrew? Do you have Mojave? – Mykola Zotko Feb 05 '19 at 19:10
  • On Linux I get a black window (see @TedKleinBergman's comment), so the code is OK. – Kingsley Feb 05 '19 at 21:57
  • After a bit of research it seems like Mac OS Mojave is the reason for my headaches! @MykolaZotko Thanks! And yes, Python 3.7 installed with Homebrew. Pygame is installed trough the package manager in Pycharm – kaffeDiem Feb 06 '19 at 08:49

1 Answers1

1

According to this issue at GitHub this is a bug of Python installed with Hombrew.

UPDATE FIX: if you download the official macOS x64 installer package of Python 3.7.2 from the official python page and then pip3 install pygame it works.

Mykola Zotko
  • 15,583
  • 3
  • 71
  • 73