简体   繁体   English

如何在tkinter的PanedWindow中设置帧的默认大小?

[英]How to set the default size of Frames inside a PanedWindow in tkinter?

I am working on a simple tkinter gui- one panedwindow and two frames inside it. 我正在研究一个简单的tkinter gui-一个窗格和其中的两个框架。 The resizing is working fine. 调整大小工作正常。 The problem is that when I add the second frame to the same panedwindow, it takes up all the space as shown in the image. 问题是,当我将第二帧添加到同一窗格时,它将占据图像中显示的所有空间。 Is there a way to set a default size for the child frames in the panedwindow and still be able to resize them using sash? 有没有一种方法可以为窗格中的子框架设置默认大小,并且仍然能够使用窗框调整它们的大小? I tried setting height using paneconfigure but it doesn't help. 我尝试使用paneconfigure设置高度,但没有帮助。 Any pointers are welcome. 欢迎任何指针。 I just want frame2 to have a smaller height than frame1 initially. 我只希望frame2的高度比最初的frame1小。

pw = tk.PanedWindow(root, orient="vertical", sashpad=1)
pw.pack(fill=tk.BOTH, expand=1)
frame1= tk.Frame(pw, bg="#CFD8DC")
frame2 = tk.Frame(pw, bg="#fafafa")
pw.add(frame1)
pw.add(frame2)

在此处输入图片说明

“ pw.add(frame1,height = 400)”这行对我不起作用,但是无论如何,我找到的解决方案与您使用“ pw.add(frame1,weight = 1)”和“ pw”的消息有关。 add(frame2,weight = 3)“行以给出平移帧的初始大小。

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

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