簡體   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