[Tutor] Tkinter, Frame and Canvas question.

Michael Lange klappnase at freenet.de
Fri Feb 24 12:05:21 CET 2006


On Thu, 23 Feb 2006 11:26:44 -0600
Hugo González Monteverde <hugonz-lists at h-lab.net> wrote:

> Hi all,
> 
> I'm running into trouble displaying some Tkinter Canvases, they keep a 
> border between themselves and there's no way I can have them display 
> without a grey gap between them.
> 
> I've narrowed the problem to the following example. I've tried all kind 
> of padding and border parameter to the Frame's pack() method and the 
> Canvas' pack() method.
> 
> Is there something I'm missing or plainly not understanding? I'd like to 
>   display canvases one next to the other without some kind of background 
> showing throug.
> 
> Thanks for taking a look, here's the example:
> 
> =======================
> 
> import Tkinter
> from Tkconstants import *
> 
> class App(Tkinter.Frame):
>      def __init__(self, master=None):
>          Tkinter.Frame.__init__(self, master)
>          self.pack(pady=0, ipady=0)
>          canvas1 = Tkinter.Canvas(self, background='#000000', borderwidth=0)
>          canvas2 = Tkinter.Canvas(self, background='#000000', borderwidth=0)
> 
>          canvas1.pack(pady=0)
>          canvas2.pack(pady=0)
> 
> if __name__ == '__main__':
>      myapp = App()
>      myapp.mainloop()

Hi Hugo,

try passing 

    highlightthickness=0

to the Canvas constructor. The hightlightthickness is the width of the border around the widget
that becomes black when the widget has keyboard focus and it probably defaults to 1. If you set highlightthickness
to 0 you should probably also set takefocus to False (if this is an option for you).

I hope this helps

Michael


More information about the Tutor mailing list