I am an enthusiast fairly new to working with python. It has been a week since I installed Pygame, and after numerous attempts, I still can’t get the Pygame window to launch or open when I run any of my programs. I have watched as many tutorials as I can, as well as reading all the articles on similar issues I could find. I have copied all of the solutions I found on other websites and the problem still persists. Stranger nonetheless, is the fact that the IDE I am using (Pycharm) rarely outputs an error message, and instead simply continues running but never launches the Pygame window. I am using Pycharm with python 3.8.1 and Pygame version 1.9.6 installed. I am using a Mac with High Sierra.
I greatly appreciate any help anyone can provide.
The below code only outputs the pygame version and the "welcome" message, but continues to run without the window ever launching.
import pygame
(width, height) = (1000, 700)
screen=pygame.display.set_mode((width, height))
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
The next code block has the exact same output as the one above.
# courtesy of Ene Uran www.daniweb.com
import pygame as pg
pg.init()
screen = pg.display.set_mode((400, 300))
pg.display.set_caption('Draw/fill rectangles using pygame')
white = 0xFFFFFF
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
yellow = 0xFFFF00
screen.fill(white, (250, 50, 77, 33))
screen.fill(red, (30, 20, 70, 120))
screen.fill(red, (140, 70, 90, 80))
screen.fill(green, (150, 80, 70, 60))
screen.fill(yellow, (200, 170, 150, 60))
screen.fill(blue, (70, 200, 100, 70))
pg.display.update()
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
raise SystemExit
The following code block also returns the same output:
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480), 0, 24)
#clock = pygame.time.Clock()
#font = pygame.font.Font(None, 32)
cycles = 0
while True:
pygame.event.get()
screen.fill(0)
# text = font.render('Cycles : %d' % cycles, True, (255, 255, 255))
# screen.blit(text, (100, 100))
cycles += 1
pygame.display.update()
This code^^ is from the original stack overflow forum for this issue: Pygame window not responding after a few seconds