External Exam Download Resources Web Applications Games Recycle Bin

Show an image from a file

image1.py

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
done = False

ace = pygame.image.load("as.gif") # see link below

while not done:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      done = True
      
  screen.blit(ace, (200, 0)) #x, y
  
  pygame.display.flip()
  
pygame.quit()

put image file + python file into same folder:


download as.gif and save to same folder as python file