[Tutor] trouble with a small Tkinter example

Evert Rol evert.rol at gmail.com
Tue Sep 21 23:10:29 CEST 2010

> I'm having trouble with this small example program:
> http://en.literateprograms.org/Bresenham%27s_line_algorithm_%28Python%29
> When I run it, I only get a blank grey window. I'm running Python 2.6 under Windows XP.
> If there's a problem with the code, I can't see it... it seems like it should work. Can anyone else try this and see if it works for them?

It appears that Tkinter (or probably the underling tcl/tk) is smart: if you create a line with the same start and end points, it won't draw a line.
Try it: create_line(10, 100, 10, 100, fill='red') won't work.

> If I stick this line in before the loop, it does draw a red line, so I know my copy of Python/Tkinter is working:
> canvas.create_line(10, 100, 5, 50 , fill='red')

More information about the Tutor mailing list