Search code examples
pythonpygamesublimetext3

Sublime text 3, pygame display is empty


I recently installed sublime text 3 and have been moving over from pycharm to sublime but have run into some difficulties with pygame. I installed python 3 and got it working, then fresh installed pygame, but when I brought over some code and ran it I got an empty pygame screen. Which looked like this:

enter image description here

I was filling the screen black and drawing a red rectangle yet none of it displayed. I am sure the program works because I tested it on both pygame and repl.it. But in case it would help here is the code for the project:

import pygame
import sys

pygame.init()

display_width = 600
display_height = 600
screen = pygame.display.set_mode((display_width, display_height))

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()

    screen.fill((0, 0, 0))
    pygame.draw.rect(screen, (255, 0, 0), ((300, 300), (20, 20)))
    pygame.display.update()

I think it has to do with something I am not setting up with sublime. Help appreciated. Thx.


Solution

  • It turns out pygame is not compatible with Mac OS Mojave so you need to use the new dev build to get it to work.

    Use pip install pygame==2.0.0.dev4