トップフレームの 3 つのラベルすべての間隔を均等にしようとしています。「見えない」ラベルの幅をハードコーディングしてそれらを分離したくありません。これは、下のフレームで後でウィンドウ サイズを拡大する必要がある場合があるためです。現在、左のラベルが残っていて、どのラベルにも属していないように見える巨大な灰色の領域があり、最後に中央と右のラベルが右側で砕かれています。これを行うより良い方法はありますか?
from tkinter import *
from tkinter import ttk
#Build buttons
def create_buttons():
for y in range(6):
for x in range(6):
ttk.Button(bot_frame, width = 5, text = str(x) + "," + str(y)).grid(column = x, row = y, sticky = W)
root = Tk()
#top frame
top_frame = ttk.Frame(root, padding = "4 4 4 4")
top_frame.grid(column = 0, row = 0, sticky = (N, E, S, W))
top_frame.columnconfigure(0, weight = 1)
top_frame.rowconfigure(0, weight = 1)
top_frame['borderwidth'] = 2
top_frame['relief'] = 'sunken'
#bottom frame
bot_frame = ttk.Frame(root, padding = "4 4 4 4")
bot_frame.grid(column = 0, row = 2, sticky = (N, E, S, W))
bot_frame.columnconfigure(0, weight = 1)
bot_frame.rowconfigure(0, weight = 1)
bot_frame['borderwidth'] = 2
bot_frame['relief'] = 'sunken'
#Top labels
left_lbl = ttk.Label(top_frame, background = 'black', foreground = 'green', width = 5, text = "left").grid(column = 0, row = 0, sticky = (N, W))
center_lbl = ttk.Label(top_frame, background = 'red', width = 6, text = 'center').grid(column = 1, row = 0, sticky = (N, E, S, W))
right_lbl = ttk.Label(top_frame, background = 'black', foreground = 'green', width = 5, text = "right").grid(column = 2, row = 0, sticky = (N, E))
create_buttons()
root.mainloop()