官术网_书友最值得收藏!

How it works…

To have a better understanding of the Pack geometry manager, we will explain step by step how it adds widgets to the parent container. Here, we pay special attention to the values of the side option, which indicates, the relative position of the widget with respect to the next one that will be packed.

First, we pack the two labels at the top of the screen. While the tk.TOP constant is the default value of the side option, we set it explicitly to clearly differentiate it from the calls where we used the tk.LEFT value:

Then, we pack the next three labels with the side option set to tk.LEFT, which causes them to be placed side by side:

Specifying the side on label_e does not really matter, as long as it is the last widget we add to the container.

Keep in mind that this is the reason why order is so important when working with the Pack geometry manager. To prevent unexpected results in complex layouts, it is common to group widgets with frames so that when you pack all the widgets within a frame, you do not interfere with the arrangement of the other ones.

In these cases, we strongly recommend that you use the Grid geometry manager since it allows you to directly set the position of each widget with one call to the geometry manager and avoids the need for additional frames.

主站蜘蛛池模板: 湘西| 桐城市| 滁州市| 新和县| 康平县| 明溪县| 定襄县| 花莲县| 富川| 东海县| 新沂市| 广灵县| 额尔古纳市| 和龙市| 克东县| 江川县| 漠河县| 上饶市| 鄯善县| 长岛县| 萨迦县| 遂川县| 广宗县| 德江县| 南华县| 紫金县| 西青区| 上高县| 上饶市| 井冈山市| 施甸县| 镇巴县| 威宁| 阳城县| 宜黄县| 北宁市| 衢州市| 盐边县| 皮山县| 南丰县| 淮安市|