[Tkinter-discuss] Canvas margins?

Bob Greschke bob at greschke.com
Mon Dec 10 01:19:18 CET 2007

Set the bd to 0: Canvas(Frm, width = x, height = ... bd = 0)

Most, if not all, systems add a border (like a width of 2 or so  
pixels) to the Canvas and the pixel counts get thrown off by that  
amount when you are trying to figure out the size of the Canvas and/or  
where to put things on the Canvas.  If you need a border to make  
things look good (like a sunken border around a graphing area) make a  
sub-Frame of your root window and set its border width to 2 or  
whatever, relief to SUNKEN, and then stick your canvas on to it.


On 2007-12-09, at 14:36, CarlG wrote:

> I thought I'd paste the code I use:
> root = Tk()
> tk_bg = "#%02x%02x%02x" % (255, 255, 224) #beige background
> root.config(bg=tk_bg, width=300, height=500)
> canvas = Canvas(root,width=300, height=500,bg=tk_bg)
> If I don't add the canvas, then the window is actually 300 by 500  
> and has
> the background color. With the canvas, the canvas is that size, and
> stretches the window a bit by having white borders/margins...
> -- 
> View this message in context: http://www.nabble.com/Canvas-margins--tp14242512p14243575.html
> Sent from the Python - tkinter-discuss mailing list archive at  
> Nabble.com.
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss

More information about the Tkinter-discuss mailing list