place(3tk)
πΈ NAME πΈ
place β the geometry manager for fixed or rubber-sheet placement π
β¨ SYNOPSIS β¨
place option arg ?arg ...?
π¦ DESCRIPTION π¦
okay so bestie, the placer is a geometry manager for Tk, and honestly it's giving main character energy. π Here's the tea: it does simple fixed placement of windows, where you literally just say the exact size and location of one window β that one's called the content β inside another window, which we call the container.
Then it ALSO does rubber-sheet placement π, where you describe the size and location of the content in terms of the dimensions of the container, so the content changes size and location in response to changes in the size of the container. Responsive queen. It ate.
And last but not least, the placer lets you mix these styles of placement, so that β for example β the content has a fixed width and height but is centered inside the container. Obsessed, actually. β¨
π«Ά place window option value ?option value ...?
Arrange for the placer to manage the geometry of a content whose pathName is window. The remaining arguments consist of one or more option-value pairs that specify the way in which window's geometry is managed. Option may have any of the values accepted by the place configure command. iykyk. π«
π place configure window ?option? ?value option value ...?
Query or modify the geometry options of the content given by window. Here's how it goes:
- If no option is specified, this command returns a list describing the available options (see
Tk_ConfigureInfofor information on the format of this list). - If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).
- If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. no cap. π«‘
The following option-value pairs are supported:
-anchorwhere β Where specifies which point of window is to be positioned at the (x,y) location selected by the-x,-y,-relx, and-relyoptions. The anchor point is in terms of the outer area of window including its border, if any. So if where isse, then the lower-right corner of window's border will appear at the given (x,y) location in the container. The anchor position defaults tonw. π-bordermodemode β Mode determines the degree to which borders within the container are used in determining the placement of the content. The default and most common value isinside. In this case the placer considers the area of the container to be the innermost area of the container, inside any border: an option of-x 0corresponds to an x-coordinate just inside the border and an option of-relwidth 1.0means window will fill the area inside the container's border.
If mode is outside then the placer considers the area of the container to include its border; this mode is typically used when placing window outside its container, as with the options -x 0 -y 0 -anchor ne. Lastly, mode may be specified as ignore, in which case borders are ignored: the area of the container is considered to be its official X area, which includes any internal border but no external border. A bordermode of ignore is probably not very useful. π
-heightsize β Size specifies the height for window in screen units (i.e. any of the forms accepted byTk_GetPixels). The height will be the outer dimension of window including its border, if any. If size is an empty string, or if no-heightor-relheightoption is specified, then the height requested internally by the window will be used. π-incontainer β Container specifies the path name of the window relative to which window is to be placed. Container must either be window's parent or a descendant of window's parent. In addition, container and window must both be descendants of the same top-level window. These restrictions are necessary to guarantee that window is visible whenever container is visible. If this option is not specified then the other window defaults to window's parent. π (yes, "the other window", that's the original's wording, we don't make the rules)-relheightsize β Size specifies the height for window. In this case the height is specified as a floating-point number relative to the height of the container:0.5means window will be half as high as the container,1.0means window will have the same height as the container, and so on. If both-heightand-relheightare specified for a content, their values are summed. For example,-relheight 1.0 -height -2makes the content 2 pixels shorter than the container. β¨-relwidthsize β Size specifies the width for window. In this case the width is specified as a floating-point number relative to the width of the container:0.5means window will be half as wide as the container,1.0means window will have the same width as the container, and so on. If both-widthand-relwidthare specified for a content, their values are summed. For example,-relwidth 1.0 -width 5makes the content 5 pixels wider than the container. π-relxlocation β Location specifies the x-coordinate within the container window of the anchor point for window. In this case the location is specified in a relative fashion as a floating-point number:0.0corresponds to the left edge of the container and1.0corresponds to the right edge of the container. Location need not be in the range 0.0-1.0. If both-xand-relxare specified for a content then their values are summed. For example,-relx 0.5 -x -2positions the left edge of the content 2 pixels to the left of the center of its container. π§-relylocation β Location specifies the y-coordinate within the container window of the anchor point for window. In this case the value is specified in a relative fashion as a floating-point number:0.0corresponds to the top edge of the container and1.0corresponds to the bottom edge of the container. Location need not be in the range 0.0-1.0. If both-yand-relyare specified for a content then their values are summed. For example,-rely 0.5 -x 3positions the top edge of the content 3 pixels below the center of its container. π¦-widthsize β Size specifies the width for window in screen units (i.e. any of the forms accepted byTk_GetPixels). The width will be the outer width of window including its border, if any. If size is an empty string, or if no-widthor-relwidthoption is specified, then the width requested internally by the window will be used. π-xlocation β Location specifies the x-coordinate within the container window of the anchor point for window. The location is specified in screen units (i.e. any of the forms accepted byTk_GetPixels) and need not lie within the bounds of the container window. β-ylocation β Location specifies the y-coordinate within the container window of the anchor point for window. The location is specified in screen units (i.e. any of the forms accepted byTk_GetPixels) and need not lie within the bounds of the container window. β
okay so important little footnote bestie: if the same value is specified separately with two different options, such as-xand-relx, then the most recent option is used and the older one is ignored. so the last one to the party wins. π
π place content window
Returns a list of all the content windows for which window is the container. If there is no content for window then an empty string is returned. π«Ά
π place forget window
Causes the placer to stop managing the geometry of window. As a side effect of this command window will be unmapped so that it does not appear on the screen. If window is not currently managed by the placer then the command has no effect. This command returns an empty string. π (it's not goodbye, it's just... unmanaged)
π§ place info window
Returns a list giving the current configuration of window. The list consists of option-value pairs in exactly the same form as might be specified to the place configure command. πβ¨
π place slaves window
Synonym for place content window. same vibe, different name, slay. π
If the configuration of a window has been retrieved with place info, that configuration can be restored later by first using place forget to erase any existing information for the window and then invoking place configure with the saved information. πΎ (save your fave fits and re-wear them later, literally)
more incoming in part 2, don't go anywhere π
β¨ FINE POINTS β¨
okay so the big glow-up here: your container window does NOT have to be the parent of the content window. like, at all. and bestie, this is useful in at least two situations, so let's get into it π
First one: for complex window layouts it means you can build a whole hierarchy of subwindows whose entire personality is just helping lay out the parent. The βreal childrenβ of the parent β meaning the windows that actually matter for your app's user interface β can still be children of the parent, but they get placed inside the windows of the geometry-management hierarchy. So what does that get you? The path names of the βreal childrenβ do not reflect the geometry-management hierarchy, which means users can specify options for the real children without ever knowing the geometry-management hierarchy exists. iconic, honestly. π
Second reason to have a container that's different from the content's parent: tying two siblings together. For example, the placer can force a window to always be positioned centered just below one of its siblings by specifying this configuration:
-in sibling -relx 0.5 -rely 1.0 -anchor n -bordermode outside
and then whenever the sibling gets repositioned in the future, the content gets repositioned right along with it. siblings that move together stay together fr fr π«Ά
Now, unlike a bunch of other geometry managers (looking at you, the packer π), the placer makes no attempt whatsoever to manipulate the geometry of the container windows or the parents of content windows. like, it does not set their requested sizes. zero. none. To control the sizes of those windows, you gotta make them windows like frames and canvases that actually give you configuration options for that purpose. placer is not your size guy, bestie, it's your position guy. periodt.
π EXAMPLE π
Make the label occupy the middle bit of the toplevel, no matter how it is resized:
label .l -text "In the\nMiddle!" -bg black -fg white
place .l -relwidth .3 -relx .35 -relheight .3 -rely .35
centered king behavior, no cap π
π SEE ALSO π
π KEYWORDS π
geometry manager, height, location, container, place, rubber sheet, content, width
and that's the whole page, bestie!! π¦ this was the place(3tk) manual page from Tk, and ngl it's lowkey one of the most underrated tools in the whole toolkit. now go place some windows and make them slay πβ¨
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1992 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms