[Tkinter-discuss] Canvas margins?

CarlG carlgiesberts at hotmail.com
Mon Dec 10 19:15:16 CET 2007


Bob, 

I tried what you suggested, but the canvas maintains it's edge.

I create the window, Tk(), I create the Frame and add it to the window, then
I create the canvas. Whatever I try with bd=0 on the canvas... and borders
on the frame, the canvas always has this white border outside its own
border. There seems to be nothing I can do about it. Could it have to do
with the order in which things are packed or fit to grid?

Carl


Bob Greschke wrote:
> 
> 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.
> 
> Bob
> 
> 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
>>
> 
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> 

-- 
View this message in context: http://www.nabble.com/Canvas-margins--tp14242512p14258270.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.



More information about the Tkinter-discuss mailing list