如何向 tkinter 窗口添加边距? [英] How to add a margin to a tkinter window?

查看:49
本文介绍了如何向 tkinter 窗口添加边距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以到目前为止我有一个简单的 python tkinter 窗口,我正在添加文本、按钮等.

So I have so far a simple python tkinter window and i'm adding text, buttons, etc.

片段:

class Cfrm(Frame):

    def createWidgets(self):

        self.text = Text(self, width=50, height=10)
        self.text.insert('1.0', 'some text will be here')
        self.text.tag_configure('big', font=('Verdana', 24, 'bold'))


        self.text["state"] = "disabled"
        self.text.grid(row=0, column=1)

        self.quitw = Button(self)
        self.quitw["text"] = "exit",
        self.quitw["command"] = self.quit
        self.quitw.grid(row=1, column=1)


    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

问题是,我想在窗口周围留出大约 15-20 像素的边距,我四处寻找,但找不到解决方案.还有

the problem is, I want to have about a 15-20 px margin around the window, I looked everywhere, and I couldn't find a solution. Also

self.text.tag_configure('big', font=('Verdana', 24, 'bold'))

不起作用.任何可能的解决方案?

doesn't work. Any possible solutions?

推荐答案

好的,这是我为问题 1 找到的解决方案:

Ok, here is the solution I found for question 1:

self.grid(padx=20, pady=20)

删除 .text 似乎改变了整个框架.我还没有解决问题2.

Removing .text seems to change the whole frame. I still haven't solved problem 2.

这篇关于如何向 tkinter 窗口添加边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆