import pygame # Have to install pygame with 'pip install pygame'
pygame.init() # Initialize pygame
window = pygame.display.set_mode((800, 600)) # Window size
pygame.display.set_caption('Window name')
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT: # If x button on window is pushed
run = False # Exit while loop
window.fill((255, 0, 0)) # Fill window with red
pygame.display.update() # Update the window to show the colour red
pygame.quit() # Quit pygame