import pygame import sys # Initialize Pygame pygame.init() # Set up the window window_width = 800 window_height = 600 window = pygame.display.set_mode((window_width, window_height)) pygame.display.set_caption("Pygame Window") # Set up colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Main game loop running = True while running: # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Fill the background with white window.fill(WHITE) # Draw pygame.draw.rect(window, BLACK, (100, 100, 50, 50)) # Update the display pygame.display.flip() # Limit frame rate pygame.time.Clock().tick(60) # Quit Pygame pygame.quit() sys.exit()