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

编程入门 行业动态 更新时间:2024-10-27 04:35:51
本文介绍了删除网格 python Tkinter 小部件之间的自动间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-30 07:53:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1391435.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   间隙   部件   Tkinter   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!