Tkinter.canvas.create_window() creates two-pixel border - is it suppress it?

723 Views Asked by At

Is anybody able to advise me how to suppress 2-pixel border of an inner canvas of an outer canvas. For example - you can see the border:

w.mainloop()
w=tk.Tk()
f=tk.Frame(w,width=300,height=300,bg='yellow')
f.pack()
c_outer=tk.Canvas(f,width=20,height=20,bg='red')
c_outer.pack()
c_inner=tk.Canvas(c_outer,width=10,height=10,bg='blue')
c_outer.create_window(0,0,anchor=tk.NW,window=c_inner)
c_inner2=tk.Canvas(c_outer,width=10,height=10,bg='green')
c_outer.create_window(10,10,anchor=tk.NW,window=c_inner2)

The content of any inner canvas is circumscribed by the 2-pixed border. Thanks for help.

1

There are 1 best solutions below

2
On

create_window isn't adding anything. If you see a border, it's there because it's part of the widget and not because create_window is adding it.

Many widgets have both a border and a highlightthickness. The latter is for creating a ring around the widget when it has the keyboard focus.

You need to set both the borderwidth and highlightthickness to zero if you don't want any decorations around the edge of the widget.