[Tutor] How do I make Python draw?

Alan G alan.gauld at freenet.co.uk
Thu Jul 28 19:20:38 CEST 2005


I found my message to Nathan, looks like I pressed the wrong
reply button in the Outlook Express newsreader. I thought I'd
forward it to the list since:
a) we don't often discuss the turtle module and
b) I ask a question at the end that I'd like an answer to! :-)

Alan G.


----- Original Message ----- 
From: "Alan G" <alan.gauld at freenet.co.uk>
To: "Nathan Pinno" <falcon3166 at hotmail.com>
Sent: Wednesday, July 27, 2005 10:15 PM
Subject: Re: How do I make Python draw?


>
>> How do I make Python draw a shape? e.g. a triangle Is there a
>> specific
>> module that I have to call, or what is the command(s)?
>
> There are several options, most involve using a GUI framework to
> create
> a Canvas widget and drawing inside that.
>
> However for your purposes a more interesting route might be to try
> the Python turtle module, it does the GUI bits for you and allows 
> you
> to draw graphics by commanding a 'turtle' pen to move on the screen.
>
> If you know logo or any other turtle implementation it will be easy,
> if not an interesting lrearning experience and a fairly easy wauy of
> drawing basic geometric shapes...
>
> You can play with turtle by importing it at a >>> prompt and 
> issueing
> commands. Here is a session to draw an equilateral triangle:
>
>>>> import turtle as t
>>>> p = t.Pen()
>>>> p.reset()
>>>> p.down()
>>>> for side in range(3):
> ...    p.forward(100)
> ...    p.left(120)
> ...
>
> And attached is a jpeg of the resultant canvas.
> (The righward horizontal line seems to be a buglet in the module
> - does anyone know how to get rid of it?)
>
> HTH,
>
> Alan G.
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: turtle.jpg
Type: image/jpeg
Size: 8279 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20050728/2703f30f/turtle.jpg


More information about the Tutor mailing list