[Tutor] Ongoing trouble with Turtle's end_fill()

Kent Johnson kent37 at tds.net
Wed Aug 6 13:50:42 CEST 2008


On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <rdmoores at gmail.com> wrote:
> For a while now I've had trouble with end_fill(). Sometimes I can use
> it to fill a figure such as a square, triangle or rectangle, but
> sometimes not.
>
> Here's a barebones script using end_fill(). As you can see, it draws a
> square twice, but fails to fill it. Pleas show me how to use it
> correctly in tandem with begin_fill().

Here is a version that does fill:
from turtle import *
import time

setup(width=1000, height=700, startx=0, starty=0)
for n in range(2):
   color_name = 'red'
   x, y = 50, 50
   color(color_name)
   print color_name
   up()
   goto(x, y)
   down()
   begin_fill()
   goto(x, -y)
   goto(-x, -y)
   goto(-x, y)
   end_fill()
   print "end_fill()"
   goto(x, y)
   time.sleep(1)
   clear()

I have no idea why this one works and yours doesn't. Your program is
very similar to the filled square in turtle.demo() which does work.

The filling is implemented by drawing a polygon on a Tkinter Canvas;
is there something strange about polygons?

Kent


More information about the Tutor mailing list