我对更改容器大小的 tkinter 按钮有疑问。我正在使用网格管理,在我的示例中我有 6 行(0-5 重量为 1 和 6 重量为 10)。我希望我的第 6 行应该高于第 0-5 行,但事实并非如此。这是我的代码示例:
class Appwindow(Tk):
def __init__(self):
super().__init__()
self.geometry('{0}x{1}'.format(self.winfo_screenwidth(), self.winfo_screenheight()))
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=3)
self.rowconfigure(0, weight=1)
self.menu_frame = None
self.show_menu_frame()
self.show_id_frame()
def show_menu_frame(self):
if self.menu_frame is None:
self.menu_frame = Frame(self, background='#56809C')
self.menu_frame.columnconfigure(0, weight=1)
for i in range(6):
self.menu_frame.rowconfigure(i, weight=1)
self.menu_frame.rowconfigure(6, weight=10)
self.menu_frame.grid(column=0, row=0, rowspan=5, sticky='nsew')
self.menu_frame.grid_propagate(False)
fon = font.Font(family='courier', size=16)
b_create_id = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Create your identyficator',
command=lambda: self.create_id_frame())
b_create_id.grid(column=0, row=0, padx=5, pady=5, sticky='nsew')
b_manage_users = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Manage users',
command=lambda: self.manage_users_frame())
b_manage_users.grid(column=0, row=1, padx=5, sticky='nsew')
b_show_database_users = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Show users database',
command=lambda: self.show_database_frame())
b_show_database_users.grid(column=0, row=2, padx=5, pady=5, sticky='nsew')
b_encrypt_cypher = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Encrypt cypher',
command=lambda: self.encrypt_cypher_frame())
b_encrypt_cypher.grid(column=0, row=3, padx=5, sticky='nsew')
b_decrypt_cypher = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Decrypt cypher',
command=lambda: self.decrypt_cypher_frame())
b_decrypt_cypher.grid(column=0, row=4, padx=5, pady=5, sticky='nsew')
b_show_options = Button(self.menu_frame, font=fon, bg='#394B59', fg='white', text='Show help',
command=lambda: self.show_help_frame())
b_show_options.grid(column=0, row=5, padx=5, sticky='nsew')
def show_id_frame(self):
if self.menu_frame is not None:
show_id_frame = Frame(self.menu_frame, bg='#394B59')
show_id_frame.grid(column=0, row=6, padx=5, pady=5, sticky='nsew')
show_id_frame.grid_propagate(False)
show_id_frame.columnconfigure(0, weight=1)
b1 = Button(show_id_frame, height=2, bg='#56809C', fg='white', text='Show Your id')
b1.grid(column=0, row=0, padx=5, pady=5,)
提前致谢