【发布时间】:2018-02-21 00:13:58
【问题描述】:
我目前正在尝试制作一个基本的 GUI,其中一个框架内的屏幕底部有 5 个按钮。我目前拥有的是一个框架中的 2 个按钮。框架被包装到底部。我正在尝试让这 2 个按钮填充框架。
##IMPORTS--------------------------------------------
from tkinter import *
import tkinter.font
##GUIWindow------------------------------------------
window = tkinter.Tk()
screen_w = window.winfo_screenwidth()
screen_h = window.winfo_screenheight()
window.geometry('%dx%d' % (screen_w, screen_h))
window.title("betaV00")
myFont = tkinter.font.Font(family = 'Helvetica', size = 12, weight = "bold")
##WIDGET_BottomButtons---------------------------------
h=6
bot_frame = Frame(window, height = int(screen_h/10), width = int(screen_w))
bot_frame.pack(side=BOTTOM)
btn_HOME = Button(bot_frame, text="Home", font=myFont, bg='green', fg='white', height=h)
btn_HOME.grid(row = 0, column = 0)
btn_LEDS = Button(bot_frame, text="LEDS", font=myFont, bg='black', fg='green', height=h)
btn_LEDS.grid(row = 0, column = 1)
bot_frame.columnconfigure(0, weight=1)
bot_frame.columnconfigure(1, weight=1)
##-----------------------------------------------------
window.mainloop()
如果按钮不在框架中,我可以让它工作。当前发生的是两个按钮没有拉伸,并排放置在中间。我可以/应该怎么做才能让这些按钮展开?
【问题讨论】:
标签: python user-interface tkinter raspbian