基本上来讲fill 就是填充, expand就是居中, 为了实现上面的功能, 用左右两个frame, 左边frame不fill, 但是expand居中, 三个按钮side left 左边的frame即可. checkbox side right 即可
botframe = tk.Frame(self.viewer)
botframe.pack(side="bottom", fill=tk.X)
botleftframe = tk.Frame(botframe)
botleftframe.pack(side="left", expand=True)
save_button = tk.Button(
botleftframe,
text="Save",
command=lambda: self.save(),
)
save_button.pack(side='left', anchor='s', expand=False)
# save_button.grid(row=0, column=0)
discard_button = tk.Button(
botleftframe,
text="Discard",
command=lambda: self.discard(),
)
discard_button.pack(side='left', anchor='s', expand=False)
# discard_button.grid(row=0, column=1)
cancel_button = tk.Button(
botleftframe,
text="Cancel",
command=lambda: self.cancel(),
)
cancel_button.pack(side='left', anchor='s', expand=False)
# cancel_button.grid(row=0, column=2)
select_all_cb = tk.Checkbutton(botframe, text='select all')
select_all_cb.pack(side="right")