turtle.py bugfix & questions

Kragen Sitaker kragen at dnaco.net
Sat Dec 30 17:48:08 EST 2000


turtle.py, which I believe is in the standard distribution (at least of
PythonWin) has a minor bug: when tracing is turned on, lines shorter
than a pixel don't get drawn at all.  If you're building long curves
made of such lines, this is a bad thing.

Here's a unidiff patch I think fixes the problem.  

--- turtle.py	Sat Dec 30 14:24:17 2000
+++ nturtle.py	Sat Dec 30 14:26:09 2000
@@ -221,6 +221,8 @@
                         self._canvas.coords(item, x0, y0, x, y)
                         self._canvas.update()
                         self._canvas.after(10)
+                    # in case nhops==0
+                    self._canvas.coords(item, x0, y0, x1, y1)
                     self._canvas.itemconfigure(item, arrow="none")
                 except Tk.TclError:
                     # Probably the window was closed!

The range controlling the loop above is range(1, 1+nhops) instead of
range(1, nhops); presumably, if it were range(1, nhops), then the last
pixel's worth of drawing would be left off the line.  This should now
be unnecessary, as the coords() call after the loop should take care of
that.

Larger questions I have: is anyone using turtle.py?
http://www.python.org/1.5/NEWS-152.txt says:

	- turtle.py is a new module for simple turtle graphics.  I'm still
	working on it; let me know if you use this to teach Python to children 
	or other novices without prior programming experience.

But it's not mentioned anywhere else I can find --- not even under
"Undocumented modules" in the library reference.

Perhaps, if nobody is using it, there is no documentation, and it's
buggy (although it looks pretty stable in the hour or so I played with
it, I did find this one bug), we should remove it from the standard
distribution.

(I found it while looking for examples of the usage of Tkinter.Canvas,
because there is no documentation for Tkinter in PythonWin --- not even
the Tcl man pages, as far as I can tell.)
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
       -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]





More information about the Python-list mailing list