2017-10-21 34 views
0

我试图显示一个窗口与tkinter有一个框架占据整个底部行。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,那么该帧将占据底行,但只占其一部分。我怎样才能让框架占据整个底部?

回答

0

您已给出选项expand=True,该选项告诉框架占用窗口中的额外空间。因此,它是窗口中唯一使用窗口中所有空间的东西。

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