我有一个网格放置顶部、中心和底部框架,然后我在中心框架内制作框架(我将它们称为子框架,因为我不知道将它们称为什么)。当我尝试在子框架内打包/网格化/放置按钮时,它将不起作用。如果我网格化按钮,它们会出现在所有顶层框架的底部,这对我来说没有任何意义,因为我将它们放在了相应的子框架中。。。这真的很难解释,但这是我能做的最好的了
from tkinter import messagebox
import math
# gui
root = tk.Tk()
root.title('Bid Generator')
root.geometry('{}x{}'.format(800, 880))
# main containers
top_frame = tk.Frame(root, bg='#00c3ff', height=75)
center = tk.Frame(root, bg='white')
footer = tk.Frame(root, bg='black', height=100)
# layout of the main containers
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
top_frame.grid(row=0, sticky="ew")
center.grid(row=1, sticky="nsew")
footer.grid(row=2, sticky="ew")
# distributing equal weight (priority) to center frame columns
center.grid_columnconfigure(0, weight=1)
center.grid_columnconfigure(1, weight=1)
center.grid_columnconfigure(2, weight=1)
center.grid_rowconfigure(0, weight=1)
center.grid_rowconfigure(1, weight=1)
center.grid_rowconfigure(2, weight=1)
center.grid_rowconfigure(3, weight=1)
center.grid_rowconfigure(4, weight=1)
center.grid_rowconfigure(5, weight=1)
center.grid_rowconfigure(6, weight=1)
center.grid_rowconfigure(7, weight=1)
center.grid_rowconfigure(8, weight=1)
center.grid_rowconfigure(9, weight=1)
center.grid_rowconfigure(10, weight=1)
center.grid_rowconfigure(11, weight=1)
center.grid_rowconfigure(12, weight=1)
# label widget for the top frame
aibs_label = tk.Label(top_frame, text='Bid Generator', bg='#00c3ff').pack()
# Supported bank frames
bank_label = tk.Label(center, text='Supported Bank?', bg="gray", height=20).grid(row=0, columnspan=3, sticky="ew")
bank_left = tk.Frame(center, bg="red", padx=10, pady=10, height=10, width=10).grid(row=1, column=0, sticky="ew")
bank_mid = tk.Frame(center, bg="green", padx=10, pady=10, height=10, width=10).grid(row=1, column=1, sticky="ew")
bank_right = tk.Frame(center, bg="blue", padx=10, pady=10, height=10, width=10).grid(row=1, column=2, sticky="ew")
bank_yes = tk.Button(bank_left, text="Yes", width=24, height=3).grid()
bank_no = tk.Button(bank_mid, text="No", width=24, height=3).grid()
bank_name = tk.Button(bank_right, text="entry", width=24, height=3).grid()
# credit cards
cc_label = tk.Label(center, text='Credit cards?', bg="gray", height=20).grid(row=1, columnspan=3, sticky="ew")
cc_left = tk.Frame(center, bg="red", height=10, width=10).grid(row=2, column=0, sticky="ew")
cc_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=2, column=1, sticky="ew")
cc_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=2, column=2, sticky="ew")
# checks frames
chks_label = tk.Label(center, text='Checks?', bg="gray", height=20).grid(row=3, columnspan=3, sticky="ew")
chks_left = tk.Frame(center, bg="red", height=10, width=10).grid(row=4, column=0, sticky="ew")
chks_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=4, column=1, sticky="ew")
chks_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=4, column=2, sticky="ew")
# payroll frames
pr_label = tk.Label(center, text='Payroll?', bg="gray", height=20).grid(row=5, columnspan=3, sticky="ew")
pr_left = tk.Frame(center, bg="red", height=10, width=10).grid(row=6, column=0, sticky="ew")
pr_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=6, column=1, sticky="ew")
pr_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=6, column=2, sticky="ew")
# sales tax frames
st_label = tk.Label(center, text='Sales Tax?', bg="gray", height=20).grid(row=7, columnspan=3, sticky="ew")
st_left = tk.Frame(center, bg="red", height=10, width=10).grid(row=8, column=0, sticky="ew")
st_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=8, column=1, sticky="ew")
st_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=8, column=2, sticky="ew")
# workers comp frames
wc_label = tk.Label(center, text='Workers Comp?', bg="gray", height=20).grid(row=9, columnspan=3, sticky="ew")
wc_left = tk.Frame(center, bg="red", height=10, width=10).grid(row=10, column=0, sticky="ew")
wc_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=10, column=1, sticky="ew")
wc_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=10, column=2, sticky="ew")
# qbox frames
qbox_label = tk.Label(center, text='Qbox?', bg="gray", height=20).grid(row=11, columnspan=3, sticky="ew")
qbox_left = tk.Frame(center, bg="red", height=100, width=10).grid(row=12, column=0, sticky="ew")
qbox_mid = tk.Frame(center, bg="green", height=10, width=10).grid(row=12, column=1, sticky="ew")
qbox_right = tk.Frame(center, bg="blue", height=10, width=10).grid(row=12, column=2, sticky="ew")
# End of line
root.mainloop()
目前没有回答
相关问题 更多 >
编程相关推荐