saving a tkinter canvas

Mickel Grönroos mickel at csc.fi
Thu Apr 1 01:10:21 EST 2004


On Wed, 31 Mar 2004, Elaine Jackson wrote:

> Newbie. Playing with the 'turtle' module and wondering if there's a way to save
> the graphics you make with it. The documentation itself has nothing to say about
> this, nor (as far as I can tell) does the FAQ list at python-dot-org. Any
> pointers would be very much appreciated.

You can save Tkinter.Canvases as PostScript using the
Tkinter.Canvas.postscript() method.

>>> import Tkinter
>>> root = Tkinter.Tk()
>>> canvas = Tkinter.Canvas(root)
>>> canvas.pack()
>>> rect = canvas.create_rectangle(10,10,100,100, fill="blue")
>>> retval = canvas.postscript(file="saved.ps", height=100, width=100, colormode="color")
>>>

/Mickel

--
Mickel Grönroos, application specialist, linguistics, Research support, CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi







More information about the Python-list mailing list