我目前正在开发一段代码,将集成到其他东西中作为设置配置器。暂时,我想要一个窗口,布局如下所示:
![Layout](https://istack.dev59.com/RicDk.webp)
其中每个带颜色的框都是一个框架。这个窗口不能调整大小,它的大小总是480x720像素。因此,我希望我使用的3个框架,即侧边栏(黄色)、容器(蓝色)和静态框(红色),始终保持相同的大小并填充窗口,就像上面的图片一样,大致比例相同(不需要完全一样)。
以下是这个窗口的代码:
self.window = tk.Tk()
self.windowHeight = 480
self.windowLength = 720
self.windowDimensions = str(self.windowLength)+"x"+str(self.windowHeight) #make diemnsions string; dimensions are set as a single string
self.window.geometry(self.windowDimensions)
self.window.resizable(width=False, height=False)
self.container = tk.Frame(self.window, relief="sunken", borderwidth=2) #instantiate new window
self.sideBar = tk.Frame(self.window, relief="sunken", borderwidth=2)
self.static = tk.Frame(self.window, relief="sunken", borderwidth=2)
self.sideBar.grid_propagate(False)
self.sideBar.grid(row=0, column=0)
self.container.grid(row=0,column=1)
self.static.grid(row=5, column=1)
self.configuratorObject = configuratorObject
audioButton = tk.Button(self.sideBar, text="Audio Page", command=lambda: self.raisePage("audioPage"))
colourButton = tk.Button(self.sideBar, text="Colours", command=lambda: self.raisePage("coloursPage"))
saveButton = tk.Button(self.static, text = "Save", state="disabled")
applyButton = tk.Button(self.static, text = "Apply", state="disabled")
audioButton.pack()
colourButton.pack()
saveButton.pack()
applyButton.pack()
我尝试更改格子的 height
和 width
参数,但它们似乎无效。那么我该如何明确定义帧的布局和大小呢?
感谢任何帮助。