Turtle module – Saving an image

from tkinter import *  # Python 3
#from Tkinter import *  # Python 2
import turtle


turtle.forward(100)
ts = turtle.getscreen()

ts.getcanvas().postscript(file="duck.eps")

This will help you; I had the same problem, I Googled it, but solved it by reading the source of the turtle module.

The canvas (tkinter) object has the postscript function; you can use it.

The turtle module has “getscreen” which gives you the “turtle screen” which gives you the Tiknter canvas in which the turtle is drawing.

This will save you in encapsulated PostScript format, so you can use it in GIMP for sure but there are other viewers too. Or, you can Google how to make a .gif from this. You can use the free and open source Inkscape application to view .eps files as well, and then save them to vector or bitmap image files.

Leave a Comment