问题描述
限时送ChatGPT账号..我在 Windows 上使用 python2.当我运行 followig 代码时,我在两个画布之间得到了一个间隙(见下图),尽管我在网格它们时没有指定填充.有没有可能删除这个?
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()
感谢您的帮助!
推荐答案
您还需要将 highlightthickness
设置为零.
You need to set highlightthickness
to zero as well.
self.c1 = tk.Canvas(..., highlightthickness=0)
来自 effbot 的画布页面 highlightthickness
解释为:
高亮边框的宽度.默认是系统特定的(通常是一两个像素).(highlightThickness/HighlightThickness)
The width of the highlight border. The default is system specific (usually one or two pixels). (highlightThickness/HighlightThickness)
这篇关于删除网格 python Tkinter 小部件之间的自动间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论