[Tutor] Ongoing trouble with Turtle's end_fill() - caused by a bug in turtle.py

Dick Moores rdmoores at gmail.com
Thu Aug 7 18:54:34 CEST 2008

On Wed, Aug 6, 2008 at 5:09 PM, Gregor Lingl <gregor.lingl at aon.at> wrote:
> This is due to a bug in turtle.py - interestingly after so many years of use
> and improvement of turtle.py there still appear new bugs from time to time.
> The bug consists in a missing update of the Canvas in the fill() function
> You can repair it by inserting a line at line#309 in turtle.py in the
> fill method as follows:
>       if self._filling:
>           path = tuple(self._path)
>           smooth = self._filling < 0
>           if len(path) > 2:
>               item = self._canvas._create('polygon', path,
>                                           {'fill': self._color,
>                                            'smooth': smooth})
>               self._items.append(item)
>               self._canvas.update()      #  <=== bug-fix
>       self._path = []
> Now for the good news:
> (1) If you have done this, not only Dick's program works as
> intended,

Yes, it does! I've pasted a version at
<http://py77.python.pastebin.com/f228f64f>. Thank you!

> (2) Python 2.6 will have a new turtle module - formerly known to some
> as xturtle.py - which has much more capabilities and which at least doesn't
> show
> this bug. Presumably there will appear others, especially in the beginning
> of
> it's use. It is contained in Python2.6 beta2, it runs also under Python2.5
> and it should be (nearly?) 100%-compatible with the old turtle module.
> Its documentation can be found here:
> http://docs.python.org/dev/library/turtle.html#module-turtle
> It would be really very helpful, if those of you who use to use turtle
> graphcis would work with this new module in order to reveal as many
> bugs as possible before the final release of Python 2.6 scheduled for
> early october 2008.

I got Python2.6 beta2 and copied its turtle.py to my Python 2.5 after
renaming it turtle26.py. By now I've spent several hours trying to
figure out how to get my program to work well with it. I don't know if
I've discovered any bugs, but here are some of the problems I have:

1. The turtle has some behavior I don't see how to eliminate. If you
refer to lines 223, 225, 227, 229, etc., you'll see that the turtle
always faces in the direction it is moving when drawing a rectangle.
Using the Python2.6 beta2 version of turtle.py, the turtle can be seen
at each corner spinning to orient itself to the new direction. I don't
want this. I thought I could remove the spinning effect by setting the
turtle's shape to a circle. But the circle is way bigger than the
default turtle. No spinning, but not what I'm after.

2. The turtle can also be seen moving from the last corner of the last
rectangle to the first corner of the next. I don't want this.

3. When the screen is cleared between cycles by line 367, the blank
screen shows for a second or so. I don't want this.
In my program using the old turtle I've had to create
colored-backgrounds by drawing a rectangle almost as large as the
screen (see my draw_background() beginning at line 365). With the new
turtle, the background color can be set by, for example,
screen.bgcolor("orange"). But even so, in the V16 I was trying to
write, that blank screen still shows for a second or so. With the old
turtle, the transition from one "background" to another seems
instantaneous. No white blank screen visible at all.

4. I've attempted to make the turtle invisible, but haven't succeeded.

I'm guessing that all the problems I've mentioned aren't the result of
bugs--rather, I just don't understand the doc.

> Of course I'd assist if questions or problems would arise.



More information about the Tutor mailing list