Create a new Python script called MouseDrawing . py and start with the following code:
import pygame
from pygame.locals import *
pygame.init ()
screen_width $=800$
screen_height $=800$
screen = pygame.display.set_mode ( (screen_width,
screen_height))
done $=$ False
white $=$ pygame. $\operatorname{Color}(255,255,255)$
while not done:
for event in pygame.event.get ():
if event. type $==$ pygame. QUIT:
done $=$ True
elif event. type $==$ MOUSEBUTTONDOWN :
pygame.draw.rect (screen, white,
(pygame.mouse.get_pos (),
$(5,5)))$
pygame.display.update ()
pygame.quit ()
When run, this script will allow you to draw a small square at the location of the mouse when you click a mouse button.