简体   繁体   English

Tkinter GUI设置为相对不随窗口调整大小

[英]Tkinter GUI set to relative does not resize with window

I'm trying to make a gui that resizes automatically to fit the window it's in, but it's not working out too well. 我正在尝试制作一个可自动调整大小的GUI,以适合其所在的窗口,但效果不太好。 I tried using relative code like this: 我尝试使用这样的相对代码:

self.console.place( relx = 0, rely = 0.1, relheight = 0.85, relwidth = 1 )

but when the window is resized, it doesn't resize the elements in it. 但是调整窗口大小时,它不会调整其中元素的大小。 The relative stuff works fine in the initial declaration of the widgets, it just doesn't resize after that. 相对的东西在小部件的初始声明中可以正常工作,但之后不会重新调整大小。 Am I doing something wrong, or am I just missing something? 我是在做错什么,还是只是想念什么?

Turns out it wasn't the fault of that code, it was simply becuase the window resizing did not automatically resize my main frame. 事实证明这不是该代码的错,只是因为窗口调整大小并没有自动调整我的主框架大小。 For future reference, when trying to make an auto-resizing window, try something along these lines and make sure you weren't making my mistake: 供以后参考,当尝试制作自动调整大小的窗口时,请尝试以下方法并确保您没有犯错:

self.pack( expand = tkinter.YES, fill = tkinter.BOTH )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM