Unusable outer edge of Tkinter canvases?

Dave Opstad dave.opstad at monotypeimaging.com
Wed May 25 11:42:48 EDT 2005


When drawing rectangles in Tkinter canvases I've noticed the outer edges 
(say 3-5 pixels) don't always draw. For instance, try typing this in an 
interactive session (Terminal in OS X or Command Prompt in Windows XP):

>>> import Tkinter as T
>>> root = T.Tk()
>>> f = T.Frame(root)
>>> f.grid()
>>> c = T.Canvas(f, width = 300, height = 300)
>>> c.grid()
>>> c.create_rectangle(1, 1, 299, 299)
>>> c.create_rectangle(3, 3, 297, 297)
>>> c.create_rectangle(5, 5, 295, 295)

On the Mac, the first two rectangles only partly show up (two sides for 
the first one and three for the second), while the third one draws 
completely. On Windows the first rectangle appears partially and the 
final two appear completely.

Is there some simple setting I'm missing? I've tried gridding the canvas 
with padx, pady and also ipadx, ipady values but nothing seems to help 
make the whole rectangle (1, 1, 299, 299) appear.

I'm using Python 2.4.1 and TclTkAqua 8.4.9 on Mac OS X 10.3.7, and 
Python 2.3.4 on Windows XP (which comes with a Tcl/Tk whose version I 
don't know).

Thanks for any insights,
Dave



More information about the Python-list mailing list