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

place

Unlike pack and grid, which automatically calculate where each new widget is added, place can be used in order to specify an exact location for a particular widget. place takes either x and y coordinates (in pixels) to specify an exact spot, which will not change as the window is resized, or relative arguments to its parent, allowing the widget to move with the size of the window.

To place a widget at (5, 10) within the window, you would write widget.place(x=5, y=10).

To keep a widget in the direct center, you would use widget.place(relx=0.5, rely=0.5).

place also takes sizing options, so to keep a widget at 50 percent width and 25 percent height of the window, add (relwidth=0.5, relheight=0.25).

place is rarely used in bigger applications due to its lack of flexibility. It can be tiresome keeping track of exact coordinates for a widget, and as things change with the application, widgets may resize, causing unintended overlapping.

For a smaller window with only one or two widgets – say a custom pop-up message – place could be a viable choice of geometry manager, since it allows for very easy centering of said widgets.

One thing to note is that place can be used alongside pack or grid within the same parent widget. This means that if you have just one widget which you need to put in a certain location, you can do so quickly without having to restructure your already packed or gridded widgets.

主站蜘蛛池模板: 汶川县| 西宁市| 茌平县| 兴业县| 赞皇县| 中宁县| 永兴县| 准格尔旗| 治多县| 进贤县| 谢通门县| 光泽县| 阿拉善左旗| 寻甸| 比如县| 香港 | 青阳县| 开封县| 获嘉县| 南汇区| 定州市| 营山县| 五家渠市| 盐城市| 冕宁县| 开封县| 神池县| 平阳县| 武威市| 宁夏| 云梦县| 宁化县| 临夏市| 鱼台县| 伊吾县| 堆龙德庆县| 凉山| 绥阳县| 巫山县| 田林县| 前郭尔|