小编car*_*tta的帖子

如何在 tkinter 中显式调整帧大小?

所以我目前正在编写一段代码,稍后将集成到其他东西中以充当设置配置器。目前,我想要一个像下面这样布局的窗口: 布局

其中每个彩色框都是一个框架。此窗口不可调整大小,并且始终为 480x720 像素。因此,我希望我使用的 3 个框架、sideBar(黄色)、容器(蓝色)和静态(红色)始终保持相同的大小并以大致相同的比例填充如上图所示的窗口(不需要是精确的)。

此窗口的代码如下

        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", …
Run Code Online (Sandbox Code Playgroud)

python tkinter python-3.x

4
推荐指数
1
解决办法
112
查看次数

标签 统计

python ×1

python-3.x ×1

tkinter ×1