使用网格几何形状和屏幕大小根据窗口大小调整小部件大小 [英] Adjust widget size according to window size using grid geometry and screen size

查看:39
本文介绍了使用网格几何形状和屏幕大小根据窗口大小调整小部件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用网格几何来根据窗口大小(最大化或最小化)更改小部件的大小.

I want to use grid geometry to change the size of widget according to size of window(maximize or minimize).

示例:

如果创建了一个窗口并且它的外观在最小化模式下得到满足,但在扩展时它会显示一些空白.我想以这种方式扩展小部件以实现该空白.

If a window is made and its look fulfilled in minimize mode but on expanding it shows some blank space .I want to expand the widget in such a way to fulfill that blank space.

如果更换了 LCD 窗口应该看起来一样.它还应该根据不同的 LCD 尺寸管理它的大小我使用了 grid_rowconfigure 和 grid_columnconfigure 方法,但在我的程序中,我删除了一个框架,然后在该窗口上显示另一个框架......它适用于第一框架,但不适用于第二框架,另一个问题是当我将我的 LCD 屏幕更改为较小的屏幕,在较大屏幕中排列的窗口中无法看到小部件.小部件与窗口的边框重合,并且由于屏幕尺寸的原因,部分小部件会从窗口中消失.

If the LCD is changed the window should look same.It should also manage its size according to different LCD size I used grid_rowconfigure and grid_columnconfigure methods, but in my program I am deleting one frame and then display another frame on that window...it works fine for the first frame but it doesn't work for the second frame and another problem is when I change my LCD screen to a smaller one, the widgets cannot be seen in a window as arranged in the bigger screen. The widget coincide with the border of window and some widgets disappear from window due to screen size.

推荐答案

您需要申请 grid_rowconfigure()grid_columnconfigure() 分别在您绘制子widgets 的父/主小部件的行和列上.

You will need to apply grid_rowconfigure() and grid_columnconfigure() on, respectively, the rows and columns of the parent/main widget where you draw the children widgets.

示例:

假设在主窗口的第一行和前 2 列上绘制了 2 个按钮.您需要像这样应用上述方法:

Suppose on the main window you draw 2 buttons on the the first row and first 2 columns. You will need to apply the methods above like this:

    main_window.grid_rowconfigure(0, weight=1) # For row 0
    main_window.grid_columnconfigure(0, weight=1) # For column 0
    main_window.grid_columnconfigure(1, weight=1) # For column 1

父/主 windowcolumnsrows 有一个与它们关联的 weight 网格选项.这个选项默认设置为 0(不扩展以填充空间),它告诉如果 master 中有额外的空间来填充,行/列应该增长多少.

The columns and rows of the parent/main window have a weight grid option associated with them. This option, which is by default set 0 (don't expand to fill space), tells how much the row/column should grow if there is extra room in the master to fill.

这篇关于使用网格几何形状和屏幕大小根据窗口大小调整小部件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆