Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pygame is opening a not responding window

I am creating my first PyGame program.When I run my program a window should PyGame window should open but whenever I run the program a not-responding window is opened.

Here is my code:

import pygame
pygame.init()

screen = pygame.display.set_mode((500,500))

Whenever I run it a not-responding PyGame window opens. How do I fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have searched the net for solutions but none of them have worked.

Also:
When I add pygame.event.get() it opens the window and instantly closes it.

I am using Python 3.9.9 on Visual Studio Code in MacOS

>Solution :

Try this

import pygame
pygame.init()

screen = pygame.display.set_mode((500,500))
black = (0, 0, 0)
running = True
while running:
      print(screen)
      screen.fill(black)
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
      pygame.display.flip()
      pygame.display.update()
pygame.quit()

in the ‘black’ variable you can choose another color by going to google and searching for ‘rgb color selector’ select the color and copy the rgb part

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading