turtle dump

Peter Otten __peter__ at web.de
Thu Jul 16 17:37:06 EDT 2009


Terry Reedy wrote:

> Michiel Overtoom wrote:
>> 
>> I got success with the following code (python 2.6.2):
>> 
>> import turtle
>> turtle.reset()
>> for i in range(4):
>>    turtle.forward(50)
>>    turtle.right(90)
>> can=turtle.getscreen().getcanvas()
>> can.postscript(file="tmp.ps")
> 
> Is raw postscript (.ps) the only thing tk can write from canvas?
> I would like to be able to import into OpenOffice document (drawing
> object) and it can import encapsulated postscript (.eps) and about 20
> other things but not, apparently, .ps.
> 
> Help on method postscript:
> postscript(self, *args, **kw) method of turtle.ScrolledCanvas instance
> 
> is spectacularly useless.

http://docs.python.org/library/turtle.html#turtle.getcanvas

The module is a bit messy, but the accompanying documentation seems OK to 
me. 

> I did not see anything similar in the list of
> about 100 attributes. The image_type of the canvas is 'photo bitmap' but
> I see no method to write that.

That's probably a bitmap that you can draw on the canvas. The Canvas is 
actually that of Tkinter, and according to

http://www.tcl.tk/man/tcl8.5/TkCmd/canvas.htm#M59

it writes Encapsulated Postscript 3.0. Also:

$ file tmp.ps
tmp.ps: PostScript document text conforming DSC level 3.0, type EPS

Try changing the file extension from .ps to .eps.

Peter




More information about the Python-list mailing list