-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_pygame.py
39 lines (28 loc) · 831 Bytes
/
03_pygame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
03_pygame.py
This script displays an image using the Pygame library.
"""
# Define the path to the image file
my_image = 'img\image5.png'
# Import necessary library
import pygame # Import Pygame library
# Initialize Pygame
pygame.init()
# Load the image using Pygame
img = pygame.image.load(my_image)
# Create a display window with the same size as the image
screen = pygame.display.set_mode(img.get_size())
# Blit (draw) the image onto the screen at position (0, 0)
screen.blit(img, (0, 0))
# Update the display
pygame.display.flip()
# Main event loop
running = True
while running:
# Check for events
for event in pygame.event.get():
# If the user closes the window, set running to False to exit the loop
if event.type == pygame.QUIT:
running = False
# Quit Pygame
pygame.quit()