Tkinter - 扭曲列大小的文本小部件 [英] Tkinter - text widget distorting column sizes
问题描述
我正在使用网格管理器,并且有两个并排的框架,以及第二行的两个框架下方的五列,每列有 1 个按钮,均匀间隔.所有都使用粘性"NSEW,因为我希望它们在我放大窗口时按比例缩放.
I am using the grid manager and have two frames side by side, and five columns with 1 button in each below the two frames in a second row, evenly spaced. All use "sticky" NSEW since I want them to scale proportionally if I enlarge the window.
当我将文本输入小部件添加到右侧框架时,它会扭曲它们下方的按钮,使其比左侧的按钮大.我不知道如何防止这种失真,或者换句话说,如何保持每列的大小相同.
When I add a text entry widget to the right frame, it distorts the buttons below them so they are larger than those to the left. I can't figure out how to prevent this distortion, or put another way, how to keep each column the same size.
文本输入小部件与行/列/权重不同的原因是什么?提前致谢!
Is there a reason why the text entry widget is not respective the row/col/weighting? Thanks in advance!
推荐答案
我认为这是因为您已为条目小部件指定了特定宽度(或正在接受默认值).由于小部件想要特定的大小,它会导致列增长以适应其子项的请求大小.
I think this is due to the fact you've given the entry widget a specific width (or are accepting the default). Since the widget wants to be a particular size, it will cause the column to grow in order to fit the requested size of its children.
一种解决方案是将条目小部件的大小设置为 1.然后,由于 E 和 W 的粘性设置,它将扩展以完全适合该列.
One solution is to set the size of the entry widget to 1. Then, because of the sticky settings for E and W, it will expand to exactly fit the column.
这篇关于Tkinter - 扭曲列大小的文本小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!