Handouts: Graphics Reference
Worked Example: Stamp Tool
File: making_tracks.py

Write a program that draws an image anywhere the user clicks.


This is our first example involving images!

You may have to first install Pillow, a tool that has code for manipulating images and drawing them onto the Canvas. Check out the installation instructions at the bottom for how to do this.

To load an image into Graphics, you can do something like the following:

stamp = canvas.create_image(x, y, "images/simba-sm.jpg")

This code loads the image simba-sm.jpg saved in the images folder in your Pycharm project and draws it at the location (x, y). You can then use canvas functions like canvas.moveto(stamp, new_x, new_y) to modify the image and move it around, just like any graphics object.

Check out the Graphics Reference for more information on images.