1

I've tried several times running code to display something in the screen but it never shows up anything, it is always a blank screen as you can see:

Blank screen

I want to draw a rectangle, but why is it not displaying?

import pygame, sys
from pygame.locals import *

def main():
    pygame.init()

    DISPLAY=pygame.display.set_mode((500,400),0,32)

    WHITE=(255,255,255)
    blue=(0,0,255)

    DISPLAY.fill(WHITE)

    pygame.draw.rect(DISPLAY,blue,(200,150,100,50))

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

main()

I'm running Python 3.7.1 and pygame 1.9.4 on macos

Miguel
  • 89
  • 2
  • 9
  • I can't reproduce this. The code works fine for me and draws a blue rectangle in a white window. The issue must be related to your system. – Rabbid76 Feb 02 '19 at 13:29
  • There's been a lot of osx related oddities lately, could you try to move in the `draw.rect()` into the while loop before the update? – Torxed Feb 02 '19 at 13:33
  • @Rabbid76 It probably is related to my system but if you could give me points to where to look – Miguel Feb 02 '19 at 14:26
  • @Torxed I tried what you said and it behaved the same way – Miguel Feb 02 '19 at 14:27

0 Answers0