【发布时间】:2019-05-28 02:32:04
【问题描述】:
我想知道是否有办法使 grids rows 和 columns 适合设置的 Frame 的大小。这样,如果我创建一个 Frame 并设置它的大小,grid 将适合 Frame 的大小。
这是我迄今为止尝试过的:
window = Tk()
frame = Frame(window)
frame.place(x=0, y=0, width=200, height=200)
title = Label(frame, text="The Title", bg="cornflower blue", height=2)
title.grid(row=0, column=0, sticky=NSEW)
sort_button = Button(frame, text="The Button", relief="groove", height=2, bg="maroon1",)
sort_button.grid(row=1, column=0, sticky=NSEW)
window.mainloop()
例如这是我当前代码的输出:
但这就是我想要的:
【问题讨论】:
标签: python python-3.x tkinter tkinter-layout