-
- wm geometry window ?newGeometry?
Get current geometry
If
newGeometry is not specified, the current geometry for
window is returned. This is the most recent geometry specified either by manual resizing or in a
wm geometry command. The format is:
widthxheight+x
+y'', where width and height are positive integers, x and y may be positive and negative integers. Thus, the following may happen:
% wm geometry .
200x200+-1024+0
Negative x positions
On Windows, the x (and probably also y) positions may be negative. This is the case, if there are two screens on an extended desktop and the second screen is placed left to the main screen. The second screen has negative y coordinates. If the main screen is located on the left upper corner of the secondary screen with 1024 pixels width, the return of "wm geometry ." will be: "200x200+-1024+0".
Set new geometry
If
newGeometry is specified, then the geometry of
window is changed and an empty string is returned.
NewGeometry has the form
=widthxheight rootflagx x rootflagy y, where any of
=,
widthxheight, or
+x
+y'' may be omitted.
Width and
height are positive integers specifying the desired dimensions of
window. If
window is gridded (see
GRIDDED GEOMETRY MANAGEMENT) then the dimensions are specified in grid units; otherwise they are specified in pixel units.
rootflagx and
rootflagy may be equal to
+ or
-. If
rootflagx is
+, then
x specifies the number of pixels between the left edge of the screen physical and the left edge of
window 's border. If
rootflagx is
- then
x specifies the number of pixels between the right edge of the screen physical and the right edge of
window 's border.
If
rootflagy is
+, then
y specifies the number of pixels between the top of the screen and the top of
window 's border. If
rootflagy is
-, then
y specifies the number of pixels between the bottom of
window 's border and the bottom of the screen.
x and
y is a position distance as specified by the corresponding rootflag value.
x and
y may be positive or negative and may have an optional
+ prefixed. This may lead to two "signs" with the rootflag as follows:
# Position window at the right of the physical screen with border 10 pixels (both solutions possible):
wm geometry . "-+10++10"
wm geometry . "-10+10"
# Position at the left edge of the secondary screen:
wm geometry . "+-1024+0"
# the leading + may not be omitted to be distinguished to the upper example
Let the application choose the size
If
newGeometry is specified as an empty string, then any existing user-specified geometry for
window is cancelled, and the window will revert to the size requested internally by its widgets.
One use case is to first set the geometry and then let the user the control and cancel the fix size:
wm geometry . "200x200+100+10"
wm geometry . ""
Windows manager and set geometry edit
LV 2008 Mar 26
Note that, at least with the X Window system, an application can only suggest/request a change in window size or location - the window manager implements policy, and can decide where to actually put the window, how big it can be, etc.
When to set the geometry when main window is shown edit
HaO 2015-12-04: On the clt thread
"tkwait visibility" on windows stalls started 2015-12-02, there was a discussion how to restore geometry on program startup.
In case of complex widgets, the geometry may only be set after the window is fully drawn once.
To avoid flickering, tombert came up with the following proposition:
wm withdraw .
wm attributes . -alpha 0
# draw all things
wm deiconify .
update idletasks
# do other things, if not "update idletasks" it not necessary
after idle {show_windows_proc}
}
proc show_windows_proc {} {
# load geometry from preferences to $geometry
wm geometry . $geometry
# now slowly increase alpha using a timer
}
See also edit