编程语言
首页 > 编程语言> > 删除网格化的python Tkinter小部件之间的自动间隙

删除网格化的python Tkinter小部件之间的自动间隙

作者:互联网

我在Windows上使用python2.当我运行followig代码时,尽管在对它们进行网格化时未指定填充,但在两个画布之间却存在间隙(请参见下图).
是否有可能删除此?

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

感谢帮助!

解决方法:

您还需要将Highlightthickness设置为零.

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

canvas page of effbot的highlightthickness解释为:

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

标签:python,tkinter,tkinter-canvas
来源: https://codeday.me/bug/20191012/1904142.html