Sebastian Hoelzl
Sebastian Hoelzl

Reputation: 363

Remove automatic gap between gridded python Tkinter widgets

I'm using python2 on Windows. When I run the followig code, I get a gap between the two canvas (see picture below), although there is no padding specified when I grid them. Is there any possibility to remove this?

import Tkinter as tk
import ttk

class App(tk.Tk):

    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        self.c1 = tk.Canvas(master=self, background='white', borderwidth=0,
                            relief=tk.FLAT)
        self.c2 = tk.Canvas(master=self, background='white', borderwidth=0,
                            relief=tk.FLAT)
        self.c1.grid(row=0, column=0, sticky=tk.NSEW)
        self.c2.grid(row=1, column=0, sticky=tk.NSEW)

        self.mainloop()

App()

enter image description here

Thanks for help!

Upvotes: 1

Views: 1190

Answers (1)

Lafexlos
Lafexlos

Reputation: 7735

You need to set highlightthickness to zero as well.

self.c1 = tk.Canvas(..., highlightthickness=0)

From the canvas page of effbot highlightthickness explained as:

The width of the highlight border. The default is system specific (usually one or two pixels). (highlightThickness/HighlightThickness)

Upvotes: 2

Related Questions