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

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.

主站蜘蛛池模板: 福州市| 中山市| 临沂市| 碌曲县| 木兰县| 上林县| 霸州市| 台前县| 东乡县| 禄劝| 麻城市| 汾阳市| 凤阳县| 聂荣县| 嘉祥县| 保亭| 正阳县| 聂拉木县| 双柏县| 满城县| 建平县| 云阳县| 邯郸县| 登封市| 江北区| 乐业县| 呼图壁县| 渑池县| 海南省| 贺州市| 沈丘县| 湖南省| 卓资县| 西乌珠穆沁旗| 宁河县| 永济市| 张家川| 专栏| 西宁市| 尉氏县| 沙河市|