tk/wm

The tk/wm command is used to interact with window managers in order to control such things as the title for a window, its geometry, or the increments in terms of which it may be resized. The tk/wm command can take any of a number of different forms, depending on the option argument. All of the forms expect at least one additional argument, #<widget>, which must be a top-level #<widget>.

The legal forms for the tk/wm command are:

Geometry Management

By default a top-level window appears on the screen in its natural size, which is the one determined internally by its widgets and geometry managers. If the natural size of a top-level window changes, then the window's size changes to match. A top-level window can be given a size other than its natural size in two ways. First, the user can resize the window manually using the facilities of the window manager, such as resize handles. Second, the application can request a particular size for a top-level window using the tk/wm geometry command. These two cases are handled identically by Tk; in either case, the requested size overrides the natural size. You can return the window to its natural by invoking tk/wm geometry with an empty geometry string.

Normally a top-level window can have any size from one pixel in each dimension up to the size of its screen. However, you can use the tk/wm minsize and tk/wm maxsize commands to limit the range of allowable sizes. The range set by tk/wm minsize and tk/wm maxsize applies to all forms of resizing, including the window's natural size as well as manual resizes and the tk/wm geometry command. You can also use the command tk/wm resizable to completely disable interactive resizing in one or both dimensions.

Gridded Geometry Management

Gridded geometry management occurs when one of the widgets of an application supports a range of useful sizes. This occurs, for example, in a text editor where the scrollbars, menus, and other adornments are fixed in size but the edit widget can support any number of lines of text or characters per line. In this case, it is usually desirable to let the user specify the number of lines or characters-per-line, either with the tk/wm geometry command or by interactively resizing the window. In the case of text, and in other interesting cases also, only discrete sizes of the window make sense, such as integral numbers of lines and characters-per-line; arbitrary pixel sizes are not useful.

Gridded geometry management provides support for this kind of application. Tk (and the window manager) assume that there is a grid of some sort within the application and that the application should be resized in terms of grid units rather than pixels. Gridded geometry management is typically invoked by turning on the setGrid option for a widget; it can also be invoked with the tk/wm grid command or by calling Tk_SetGrid. In each of these approaches the particular widget (or sometimes code in the application as a whole) specifies the relationship between integral grid sizes for the window and pixel sizes. To return to non-gridded geometry management, invoke tk/wm grid with empty argument strings.

When gridded geometry management is enabled then all the dimensions specified in tk/wm minsize, tk/wm maxsize, and tk/wm geometry commands are treated as grid units rather than pixel units. Interactive resizing is also carried out in even numbers of grid units rather than pixels.


Corresponding Tcl/Tk command:

wm ...

Bugs

Most existing window managers appear to have bugs that affect the operation of the tk/wm command. For example, some changes won't take effect if the window is already active: the window will have to be withdrawn and de-iconified in order to make the change happen.


© Author | Home | Sitemap