News about turtle graphics

2 views
Skip to first unread message

Gregor Lingl

unread,
Jun 22, 2006, 6:37:14 PM6/22/06
to edu...@python.org, edup...@googlegroups.com, vce...@canterburyschool.org
Hi educators!

One of the hardest problems I've encountered upto now
is to decide, when a piece of software is ready to be
be published.

I've decided, that my new turtle graphics module ready
now. A package, which additionally contains some
example scripts. a tiny demoViewer and some documentation
can be downloaded from:

http://ada.rg16.asn-wien.ac.at/~python/xturtle

From now on it's the user community, which will largely
determine the future development of the module. I hope
that it will grow to more than one user (which is me)
soon. (*) And I'm willing to continue development (preferably
in cooperation with others) until it's considered a really
useful tool by the community.

In my opinion it should replace the current turtle.py in
the standard distribution. We will see if others join
me in this respect ...

(Please note, that xturtle.py is a complete reimplementation
of what I've shown to you some ten weeks ago.)

For now I'll not write too much about it, but ask you for
feedback and contributions to a discussion about the module.
(You'll find some more information on the webpage mentioned
above!)

However, I'll give a talk at Europython 2006 on July 5th about:

xturtle - an extended turtle module for Python as a vehicle
for teaching programming concepts.

For this, too, your feedback will be welcome. And you'll get
back the slides of the talk ;-)

Regards,
Gregor Lingl

(*) This hope seems reasonable since I intend to use it in
the forthcoming 2nd edition of "Python für Kids"


Andre

unread,
Jun 22, 2006, 7:15:56 PM6/22/06
to edupython

Gregor Lingl wrote:
> Hi educators!
>
> One of the hardest problems I've encountered upto now
> is to decide, when a piece of software is ready to be
> be published.
>
> I've decided, that my new turtle graphics module ready
> now. A package, which additionally contains some
> example scripts. a tiny demoViewer and some documentation
> can be downloaded from:
>
> http://ada.rg16.asn-wien.ac.at/~python/xturtle
>

Very nice! I tried about 10 demos and they all performed very well,
except for the muorhuhn game which did not work at all (at least, not
from the demo viewer).

> From now on it's the user community, which will largely
> determine the future development of the module. I hope
> that it will grow to more than one user (which is me)
> soon. (*) And I'm willing to continue development (preferably
> in cooperation with others) until it's considered a really
> useful tool by the community.

Sorry :-( I'm busy with two other projects (rur-ple and crunchy
frog) ... but I would encourage others to have a look. It's really
impressive!

André

Gregor Lingl

unread,
Jun 22, 2006, 7:49:20 PM6/22/06
to edup...@googlegroups.com
Andre schrieb:

> Gregor Lingl wrote:
>
>> Hi educators!
>>
>> ...

> Very nice! I tried about 10 demos and they all performed very well,
> except for the muorhuhn game which did not work at all (at least, not
> from the demo viewer).
>
>
Thanks for your interest. I found the error:

Please rename the file

landscape.gif

to

landschaft.gif

which is, what is expected in moorhuhn.py.

I've corrected this now in the turtle.zip, so alternatively you may download
the corrected version.
>> ...


>>
>
> Sorry :-( I'm busy with two other projects (rur-ple and crunchy
> frog) ... but I would encourage others to have a look. It's really
> impressive!
>
> André
>

Thanks for your friendly judgment. I can understand you, as I also would
like to have a closer
look at rur-ple, but couldn't find the time to do so, when I was working
on xturtle.py

I've also had a short glance at crunchy frog (now it has some graphics
support) and I wonder
if it could be adapted to xturtle.py - namely because there is a
relativly small interface,
the class TurtleScreenBase, which has to be implemented to get all of
the turtle module
to some graphics tool. Perhaps I'll examine this in the near future.
What's your opinion?

Regards,
Gregor

Andre

unread,
Jun 22, 2006, 9:41:37 PM6/22/06
to edupython
Gregor Lingl wrote:
> Andre schrieb:
> > Gregor Lingl wrote:
> >
> >> Hi educators!
> >> ...
> > Very nice! I tried about 10 demos and they all performed very well,
> > except for the muorhuhn game which did not work at all (at least, not
> > from the demo viewer).
> >
> Thanks for your interest. I found the error:
> Please rename the file
> landscape.gif to landschaft.gif
>
Done, and it works. I had played before with some other version of
moorhuhn. My first reaction in trying yours was: "The mouse handling
makes it clumsy and a bit difficult, and the "other" moorhuhn I played
with was *much* better. Then it dawned on me that this was a
*fantastic* demo that went well beyond what is normally possible for
turtle graphics. (It was so good, I had forgotten what I was using!)

(reading again what I wrote above, it may give the wrong impression,
but I am not sure how to say it. I would not have expected to see
something as good as this within a turtle module; it really took me by
surprise!)

[snip]


> >
> Thanks for your friendly judgment. I can understand you, as I also would
> like to have a closer
> look at rur-ple, but couldn't find the time to do so, when I was working
> on xturtle.py

I hope you find the time as I like to get feedback (both positive and
negative). I'm getting very close to releasing version 1.0, after
which I'm likely to take a break from it. (I may release version 0.9.9
tonight!)

I believe that one of the main strengths of rur-ple are the lessons.
Turtle graphics environment are nice, but without a set of lessons, I
don't think they can be used to their full potential by the average
teacher. (Of course, I imagine that your book is sufficient for German
readers.)

> I've also had a short glance at crunchy frog (now it has some graphics
> support) and I wonder
> if it could be adapted to xturtle.py - namely because there is a
> relativly small interface,
> the class TurtleScreenBase, which has to be implemented to get all of
> the turtle module
> to some graphics tool. Perhaps I'll examine this in the near future.
> What's your opinion?

I think it might be both quite difficult and very easy to make crunchy
frog and xturtle work together in a seemless fashion. (I know, it's a
contradiction.)

Difficult:
In crunchy frog, graphics are currently created by translating
user-written python code
into javascript that is drawing within an html <canvas> (supported by
Firefox, Safari and Opera but not currently supported by Internet
Explorer, although there are ways to make it work). The graphics
created are static ones. It is possible to do some animation using
javascript but I don't know of an easy way to translate python code
into javascript and do the kind of animation required for turtle
graphics. [I believe it will be different for rur-ple type of
graphics, as the robot moves by discrete steps, and one can use the
javascript timeout function to create such animations. This is
something I plan to explore this summer.]

Very easy:
Crunchy frog is designed as a conduit between a regular html page and a
"Python back-end". The idea is to use html forms (or ajax based
interaction) to send python code to the back end, and display the
result back within the web page. One extension I want to work on soon
(and I've done a quick and dirty working pygame prototype a while ago)
is to launch an external Python process that way. What I would see is
simply to launch an xturtle program (tkinter based) from the
"crunchified" web page. This appears to be very easy!

What we really need are html-based lessons that crunchy frog could
display and that contain suggested exercise for the reader. The user
could type in the required code on the webpage, click a button and see
the xturtle program launched. In some ways, Crunchy Frog is akin to
Leo, the literate programmer (as suggested originally by Knuth), where
the user-written documentation is mixed in with the Python code. The
difference here is that the documentation (tutorials) is supplied by
the "teacher" to be displayed by Crunchy Frog which is then used as a
simple Python editor (or, rather, as an Integrated Learning
Environment, including other features like easy handling of doctest as
teaching tools).

I would *love* to have some sample xturtle lessons to bundle (together
with xturtle.py) with the next Crunchy Frog release. If you can write
a sample lesson for beginning Python users that includes suggested
exercise, I could take care of the rest.
(A German lesson, together with an English translation would be great
as Crunchy Frog needs to be adaptable to other languages - if you
supply such a lesson, provided it is short enough, I will even
translate it into French. ;-)

Regards,

André

kirby urner

unread,
Jun 23, 2006, 1:23:37 AM6/23/06
to Gregor Lingl, edu...@python.org, edup...@googlegroups.com
Thank you Gregor. I am studying your web site and product.

I'm not expecting to make it to EuroPython this year, but maybe next.
In the meantime, I look forward to continued collaborations via
edu-sig.

Kirby


On 6/22/06, Gregor Lingl <gli...@aon.at> wrote:
> Hi educators!
>

Gregor Lingl

unread,
Jun 23, 2006, 7:02:22 AM6/23/06
to Dethe Elza, edup...@googlegroups.com, edu...@python.org
Dethe Elza schrieb:
> Hi Gregor,
>
> I tried it out on OS X and it works great. There are some very
> beautiful demos. I will try to dig under the hood at some point and
> see if it would be feasible to replace Tinker with Cocoa
> (conditionally, if the user has PyObjC installed, otherwise it could
> fall back to Tkinter).
>
>
Ah fine, please do so - (and keep us informed).
There is one single class, TurtleScreenBase, which contains the
interface to Tkinter. It was
one of my primary design decisions, to keep this small and isolated. (I
had in mind e.g. porting
it to Jython). So at first concentrate on that small part of the thing.

Unfortunately this part of the software is still not very well
documented (albeit it doesn't
contain special intricacies). If you have questions, feel free to ask.

(Of course that doesn't apply to the demoViewer ...)

Best wishes
Gregor
> Putting it into Javascript would probably be possible, and there is
> even a workaround for <canvas> in IE, but the performance would
> definitely take a hit.
>
> Great work. I should take a look at Rur-ple now...
>
> --Dethe
> _______________________________________________
> Edu-sig mailing list
> Edu...@python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>
>
>

kirby urner

unread,
Jun 23, 2006, 9:54:47 AM6/23/06
to Gregor Lingl, Dethe Elza, edup...@googlegroups.com, edu...@python.org
Yes, I'm liking the demos too and will say something in my blog today.
Question: say a student has just booted IDLE and wants to run the
minimum import and turtle commands to draw a triangle, what would that
look like? I believe I will be able to answer my own question with
just a little more study. I am wondering if an xturtle package with
an __ini__.py would make sense.

Kirby

Gregor Lingl

unread,
Jun 23, 2006, 10:16:30 AM6/23/06
to kirby urner, Dethe Elza, edup...@googlegroups.com, edu...@python.org
kirby urner schrieb:

> Yes, I'm liking the demos too and will say something in my blog today.
> Question: say a student has just booted IDLE and wants to run the
> minimum import and turtle commands to draw a triangle, what would that
> look like?
IDLE 1.2b1 ==== No Subprocess ====
>>> from xturtle import *
>>> onClick(goto)
>>>

;-)


> I believe I will be able to answer my own question with
> just a little more study. I am wondering if an xturtle package with
> an __ini__.py would make sense.
>

What for?
Gregor
> Kirby
>

Vern Ceder

unread,
Jun 23, 2006, 10:47:15 AM6/23/06
to edup...@googlegroups.com, edu...@python.org
Gregor,

Well done! xturtle.py is a truly impressive re-implementation and
enhancement. I ran all of the demos without problems on a Linux (Ubuntu
Dapper) machine and was very impressed with the speed, as well as the
number, variety and quality of the demos.

I would certainly think that (after testing ;) ) xturtle might replace
the current turtle.py. I had also been thinking about what would be
involved in porting turtle.py to Jython and your refactoring makes that
a much more appealing possibility.

I saw that you were presenting at EuroPython - best of luck with that
presentation. I'll be presenting on Python programming at NECC, a
national educational computing conference, on July 7, so if you don't
mind I will mention xturtle then.

One final thought - even though the file is large, I would consider
including at least some demo code in the file itself. Maybe it's just
me, but I like the idea of being able to demo the module even if it gets
separated from all other files in the package. Things like that can
happen. :)

Cheers,
Vern

--
This time for sure!
-Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137

Gregor Lingl

unread,
Jun 23, 2006, 11:07:12 AM6/23/06
to edup...@googlegroups.com, edu...@python.org
Vern Ceder schrieb:

> Gregor,
>
> Well done! xturtle.py is a truly impressive re-implementation and
> enhancement. I ran all of the demos without problems on a Linux (Ubuntu
> Dapper) machine and was very impressed with the speed, as well as the
> number, variety and quality of the demos.
>
> I would certainly think that (after testing ;) ) xturtle might replace
> the current turtle.py.
btw, who is responsible for a decision about this? I even don't know
whom I should contact.
I think you should know ;-)

> I had also been thinking about what would be
> involved in porting turtle.py to Jython and your refactoring makes that
> a much more appealing possibility.
>
If you have more concrete ideas concerning this, please let me know.

> I saw that you were presenting at EuroPython - best of luck with that
> presentation. I'll be presenting on Python programming at NECC, a
> national educational computing conference, on July 7, so if you don't
> mind I will mention xturtle then.
>
>
Of course not. (Naturally) I'm very interested in making xturtle
pupular. I did it because I'm
convinced that it could help popularize (is this an English word?)
Python in the educational
arena as well as make life of the educators a bit easier (and funnier (-
in the sens of 'Have fun!')).

> One final thought - even though the file is large, I would consider
> including at least some demo code in the file itself. Maybe it's just
> me, but I like the idea of being able to demo the module even if it gets
> separated from all other files in the package. Things like that can
> happen. :)
>

That's right. One could use 'oldTurtleDemo.py' for this (now that gets
imported). I'll think about it
and perhaps I'll have some ideas to make it more funny .... I'll do a
proposal.

(I'm glad, that all of you expressed, that you like xturtle much!)

Best wishes
Gregor
> Cheers,
> Vern
>

kirby urner

unread,
Jun 23, 2006, 1:12:45 PM6/23/06
to Gregor Lingl, Dethe Elza, edup...@googlegroups.com, edu...@python.org
> > I believe I will be able to answer my own question with
> > just a little more study. I am wondering if an xturtle package with
> > an __ini__.py would make sense.
> >
> What for?
> Gregor
> > Kirby
> >

>>> from xturtle import *

Traceback (most recent call last):
File "<pyshell#0>", line 1, in -toplevel-
from xturtle import *
ImportError: No module named xturtle

Because I want all my xturtle stuff in a subfolder beneath
site-packages (on either Linux or Windows).

I could make it a package myself, but I think for distribution
purposes, a distro with as many files as yours (including
documentation) deserves its own subdirectory.

Kirby

francois schnell

unread,
Jun 24, 2006, 2:40:42 PM6/24/06
to Gregor Lingl, edu...@python.org, edup...@googlegroups.com
On 23/06/06, Gregor Lingl <gli...@aon.at> wrote:
Hi educators!

One of the hardest problems I've encountered upto now
is to decide, when a piece of software is ready to be
be published.

Hello,

Well, I don't know but if it can help I've just jogged with a podcast conference (IT conversations podcast feed) saying that:

"Great quyote from Michael Goldfarber, the Einstein of Attention. "The best guarantee for attention is living your life as openly as possible, expressing yourself as publicly as possible as early as possible." Information attracts attention: to get attention, you need to give information. Receiving information makes you influential. There's a definition we came to that suggests that influence is the amount of attention you get relative to the amount of attention you give."
http://radar.oreilly.com/archives/2006/03/etech_seth_goldstein.html
 

I've decided, that my new turtle graphics module ready
now. A package, which additionally contains some
example scripts. a tiny demoViewer and some documentation
can be downloaded from:

http://ada.rg16.asn-wien.ac.at/~python/xturtle

Wow !
- The demos are great.
- The doc is very clear and I like to have everything in one page (helps me  to find quickly what I search for through a "search")


From now on it's the user community, which will largely
determine the future development of the module. I hope
that it will grow to more than one user (which is me)
soon. (*)

I gave a quick test to the module and I'm already having fun to enslave your turtles to a liberlab board ( http://www.liberlab.net/ ) :

http://www.flickr.com/photos/frenchy/173828694/
http://www.flickr.com/photos/frenchy/173828762/

And I'm willing to continue development (preferably
in cooperation with others) until it's considered a really
useful tool by the community.

In my opinion it should replace the current turtle.py in
the standard distribution. We will see if others join
me in this respect ...

Well I'm voting for your module but my influence here is Null ;)

(Please note, that xturtle.py is a complete reimplementation
of what I've shown to you some ten weeks ago.)

For now I'll not write too much about it, but ask you for
feedback and contributions to a discussion about the module.
(You'll find some more information on the webpage mentioned
above!)

Just one thing I messed with : I didn't succeed to set the heading with a .gif picture (as a turtle)

ie if I do something like (t1 is my turtle):

t1.addshape("mypict.gif")
t1.shape("mypict.gif")

t1.setheading(myangle)

=> everything is fine but the .gif pict. itself doesn't turn.

On the contribution side I'm interested to translate the doc in French.

Question: I didn't see any informations about the licencing (and I can't access your website for now which seems down), do you already have a plan for that ?


However, I'll give a talk at Europython 2006 on July 5th about:

xturtle - an extended turtle module for Python as a vehicle
for teaching programming concepts.

After having the chance to meet Papert and reading his books I do think the concepts behind the turtle geometry (and Logo) are really powerful. I'm glad all this have a new great chance in a web era through the MIT One Laptop Per Child program (Logo came in a pre-web era).

Concerning Europython, I'll finally be able to come. I'll also  take a liberlab board if you want to see your turtles "jumping" around.

For this, too, your feedback will be welcome. And you'll get
back the slides of the talk ;-)

I think it would be good if there is also a video or audio recording for people who can't come.
I don't know if Europython will do that or what is their policy but I have a reasonably good DV camcorder, then,  if there's no objections I could record it and dump it on Google video (or whatever) if it's fine with you.
I could also do that for other conf. If people agree/want to.

I also saw that the education track begins only the last day. I would appreciate to meet/identify the pysthonist people interested in education before the last day (to learn from and drink a beer maybe ;) ), are their other people following this list who will go to Europython 2006 ?

Thanks for making me having fun with your turtles.

cheers

francois

Regards,
Gregor Lingl

(*) This hope seems reasonable since I intend to use it in
the forthcoming 2nd edition of "Python für Kids"


Gregor Lingl

unread,
Jun 29, 2006, 11:06:58 AM6/29/06
to Brad Miller, edu...@python.org, edup...@googlegroups.com
Brad Miller schrieb:
> Hi Gregor,
>
> The more I play with the new xturtle the more I like it. Thanks!
> I've been thinking about the following extension to TurtleScreenBase
> and I wonder what you and others think of the idea.
>
> I like the fact that the turtle starts out in a coordinate system with
> 0,0 in the middle of the window, and I like the fact that for
> beginning students 1 unit == 1 pixel on the screen. But, I think that
> after a student has used the turtle to plot a sin or cos curve and
> learned about scaling the values to make the plot visible in the
> window it would be nice to place the turtle in a world coordinate
> system that matched whatever application the student was working on.
> For example the gravitaion examples could be done in meters. Let
> TurtleScreenBase take care of the translation and scaling after for
> you. The API could be extended by a single call
> setWorldCoordinates(llx,lly,ulx,uly) that specifies the world
> coordinates of the lower left corner of the screen and the upper
> right. (This is very similar to the ortho2 call in openGL. Note, if
> the student does not call setWorldCoordinates then the turtle
> functions just as it does now.
>
> I've already added this capability to the turtle.py that Vern wrote
> for Python 2.5 and I don't think it would be too hard to add to
> TurtleScreenBase. What do you all think? Would this be a useful
> addition? Gregor, is this something you already have on your todo
> list? Would you be interested?
>
I've thought about this,but abandoned it for the moment. The xturtle API
is already
rather 'fat' as the core developers complained.

I'll appreciate your proposal. So do it, for now as an experiment.
At the moment I'm very busy (and have to concentrate on my Europython talk),
but I've several points to say on this. Please wait until end of next
week, then
I'll be ready to discuss this in depth.

Thanks again for your idea
Gregor

(P.S.: When you have done his enhancement, perhaps you could devise
some interesting gravitational systems with real world coordinates?)

> Thanks,
>
> Brad
>

Brad Miller

unread,
Aug 2, 2006, 6:14:17 PM8/2/06
to edup...@googlegroups.com
On 6/29/06, Gregor Lingl <gli...@aon.at> wrote:


>
I've thought about this,but abandoned it for the moment. The xturtle API
is already
rather 'fat' as the core developers complained.

I'll appreciate your proposal. So do it, for now as an experiment.
At the moment I'm very busy (and have to concentrate on my Europython talk),
but I've several points to say on this. Please wait until end of next
week, then
I'll be ready to discuss this in depth.


Hi Gregor,
 
I finally got around to implementing world coordinates for xturtle.  My first goal was 'do no harm', and so even after my modifications all the demos continue to run just fine.  I've been testing it with some simple examples and things seem to work fine.

If you want to have a look at the code you can grab it from here:

http://knuth.luther.edu/~bmiller/downloads/xturtle.py

Basically What I did was the following:

  1. Add new method to TurtleScreenBase called setWorldCoordinates(llx,lly,urx,ury) This method lets the user set the canvas coordinates to whatever they want specifying the lowerleft point and the upper right point of the canvas.  This method is meant to be called once at the beginning of your program.
  2. Modified the _drawline and _drawpoly methods to scale the the points on the line appropriately.  Also added a keyword parameter called scale
  3. Modified the _drawturtle function to create a turtle in the new coordinate system and then have _drawpoly draw the turtle unscaled.  This is kind of a nasty interdependency between the screen and the turtle and the canvas.
  4. Added a Turtle class that only adds one method (setWorldCoordinates) which passes through the call to set the coordinates to the screen.  This method could probably be done in RawPen, but I wanted to instantiate a Turtle not a Pen.
If you have any suggestions for a better implementation strategy I'd be happy to here them!

Here is a really simple example of just using the turtle to plot some points inside the upper right quadrant of the unit circle.  A monte carlo simulation for estimating pi.  I will, of course, be working on some additional tests and demos.

import random
import math
import xturtle

def inCircle(x,y):
   d = math.sqrt(x**2 + y**2)
   if d <= 1:
      return True
   else:
      return False

def main(): 
    t = xturtle.Turtle()
    t.setWorldCoordinates(-1.0,-1.0,1.0,1.0)

    total = 30000
    circle = 0
    t.up()
    for i in range(total):
        x = random.random()
        y = random.random()
        t.goto(x,y)
        if inCircle(x,y):
            t.color("blue")
            t.dot()
            circle = circle + 1
        else:
            t.color("red")
            t.dot()      
    pi = float(circle)/total * 4  
    print pi   
main()

Brad

Reply all
Reply to author
Forward
0 new messages