繁体   English   中英

Tkinter框架占据了窗口的全部底部行

[英]Tkinter frame to occupy full bottom row of window

我正在尝试显示带有tkinter的窗口,该窗口的框架占据整个底部行。

这是我现在拥有的代码:

import openpyxl, PIL.Image, sys
from tkinter import *

class App(object):
    def __init__(self, root):
        self.root = root
        w, h = root.winfo_screenwidth() * .9, root.winfo_screenheight() * .9
        root.geometry("%dx%d+0+0" % (w, h))

        root.title('Squirrel Project')
        root.wm_iconbitmap('Squirrel.ico')

        buttonFrame = Frame(root, width = w, height = 25, padx = 15, pady = 15, bg = 'blue')
        buttonFrame.pack(fill = X, expand = True, side = BOTTOM)

        saveButton = Button(buttonFrame, text = 'Save', command = self.save).pack(side = LEFT)

使用上面的代码,框架占据了窗口的整个宽度,但位于中间行。 如果我从buttonFrame.pack删除fill = X, expand = True ,则该框架将占据底部一行,但仅占据其中一部分。 如何使框架占据整个底行?

您已经提供了expand=True选项,它告诉框架占用窗口中的额外空间。 因此,由于它是窗口中唯一的东西,因此它会使用窗口中的所有空间。

如果您不希望它占用额外的空间,请忽略该选项或将其设置为False

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM