[Tutor] Tkinter, Frame and Canvas question.

Gregor Lingl glingl at aon.at
Thu Feb 23 23:14:53 CET 2006


Hi Hugo,

some experiments showed, that the following code - using borderwidth=-2 
-  works as you desired, at least on my windows machine:

import Tkinter
from Tkconstants import *

class App(Tkinter.Frame):
   def __init__(self, master=None):
     Tkinter.Frame.__init__(self, master)
     self.pack()
     canvas1 = Tkinter.Canvas(self, background='#000000', borderwidth=-2)
     canvas2 = Tkinter.Canvas(self, background='#000000', borderwidth=-2)
     canvas1.pack(pady=0)
     canvas2.pack(pady=0)

if __name__ == '__main__':
      myapp = App()
      myapp.mainloop()

--------
Alas, there is some strange anomaly: it only does so (i. e. doesn't
display that gray bar between the canvases) when run from IDLE or
by double-clicking the renamed file test.pyw or run from the
command window with the command: python test.py.
Double-clicking test.py performs differently(!) and still shows the 
border between the two canvases. Who understands? (Or do you think my
python installation is in a corrupted state?)

Regards, Gregor



Hugo González Monteverde schrieb:
> 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()
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
Gregor Lingl
Reisnerstrasse 3/19
A-1030 Wien

Telefon: +43 1 713 33 98
Mobil:   +43 664 140 35 27

Website: python4kids.net


More information about the Tutor mailing list