Lesson 51 of 51 · Advanced
Saving Your Artwork
Save your turtle artwork as an image file.
Python
from turtle import *
from PIL import ImageGrab
bgcolor("black")
color("cyan")
pensize(3)
speed(0)
for i in range(36):
for j in range(4):
forward(100)
right(90)
right(10)
screen = getscreen()
canvas = screen.getcanvas()
x = canvas.winfo_rootx()
y = canvas.winfo_rooty()
x1 = x + canvas.winfo_width()
y1 = y + canvas.winfo_height()
ImageGrab.grab((x, y, x1, y1)).save("art.png")
done()Output

1
PostScript Output
screen.getcanvas().postscript(file="art.eps") saves as EPS. Convert to PNG online or with Pillow.