jjclarkson jjclarkson - 1 year ago 322
Python Question

Python Turtle Module- Saving an image

I would like to figure out how to save a bitmap or vector graphics image after creating a drawing with python's turtle module. After a bit of googling I can't find an easy answer. I did find a module called canvas2svg, but I'm very new to python and I don't know how to install the module. Is there some built in way to save images of the turtle canvas? If not where do I put custom modules for python on an Ubuntu machine?

Answer Source
from Tkinter import *
from turtle import *
import turtle

ts = turtle.getscreen()


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download