1wm(n)                        Tk Built-In Commands                        wm(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       wm - Communicate with window manager
9

SYNOPSIS

11       wm option window ?args?
12_________________________________________________________________
13

DESCRIPTION

15       The  wm  command  is  used to interact with window managers in order to
16       control such things as the title for a window,  its  geometry,  or  the
17       increments  in  terms  of  which it may be resized.  The wm command can
18       take any of a number of different forms, depending on the option  argu‐
19       ment.   All  of the forms expect at least one additional argument, win‐
20       dow, which must be the path name of a top-level window.
21
22       The legal forms for the wm command are:
23
24       wm aspect window ?minNumer minDenom maxNumer maxDenom?
25              If minNumer, minDenom, maxNumer, and maxDenom are all specified,
26              then  they  will  be passed to the window manager and the window
27              manager should use them to enforce a range of acceptable  aspect
28              ratios  for  window.   The aspect ratio of window (width/length)
29              will be constrained to lie between minNumer/minDenom and  maxNu‐
30              mer/maxDenom.   If  minNumer  etc.  are  all  specified as empty
31              strings,  then  any  existing  aspect  ratio  restrictions   are
32              removed.   If  minNumer  etc.  are  specified,  then the command
33              returns an empty string.  Otherwise, it returns a Tcl list  con‐
34              taining four elements, which are the current values of minNumer,
35              minDenom, maxNumer, and maxDenom (if no aspect restrictions  are
36              in effect, then an empty string is returned).
37
38       wm attributes window
39
40       wm attributes window ?option?
41
42       wm attributes window ?option value option value...?
43              This  subcommand  returns  or  sets platform specific attributes
44              associated with a window. The first form returns a list  of  the
45              platform  specific  flags  and  their  values.  The  second form
46              returns the value for the specific option. The third  form  sets
47              one or more of the values. The values are as follows:
48
49              All platforms support the following attributes (though X11 users
50              should see the notes below):
51
52              -fullscreen
53                     Places the window in a mode  that  takes  up  the  entire
54                     screen,  has  no borders, and covers the general use area
55                     (i.e. Start menu and taskbar on Windows, dock and menubar
56                     on OSX, general window decorations on X11).
57
58              -topmost
59                     Specifies  whether  this  is  a  topmost window (displays
60                     above all other windows).
61
62              On Windows, the following attributes may be set.
63
64              -alpha Specifies the alpha transparency level of  the  toplevel. │
65                     It  accepts  a  value from 0.0 (fully transparent) to 1.0 
66                     (opaque).  Values outside that range will be constrained. │
67                     This  is  supported  on Windows 2000/XP+.  Where not sup‐ │
68                     ported, the -alpha value remains at 1.0.
69
70              -disabled
71                     Specifies whether the window is in a disabled state.
72
73              -toolwindow
74                     Specifies a toolwindow style window (as  defined  in  the
75                     MSDN).
76
77              -transparentcolor
78                     Specifies  the  transparent  color index of the toplevel. │
79                     It takes any color value accepted by Tk_GetColor.  If the │
80                     empty string is specified (default), no transparent color │
81                     is used.  This is supported on Windows  2000/XP+.   Where │
82                     not supported, the -transparentcolor value remains at {}.
83
84              On Mac OS X, the following attributes may be set.
85
86              -alpha Specifies the alpha transparency level of the window.  It
87                     accepts a value  from  0.0  (fully  transparent)  to  1.0
88                     (opaque), values outside that range will be constrained.
89
90              -modified
91                     Specifies  the  modification  state of the window (deter‐
92                     mines whether the window close widget contains the  modi‐
93                     fication  indicator  and  whether the proxy icon is drag‐
94                     gable).
95
96              -notify
97                     Specifies process notification  state  (bouncing  of  the
98                     application dock icon).
99
100              -titlepath
101                     Specifies  the  path of the file referenced as the window
102                     proxy icon (which can be dragged and dropped in  lieu  of
103                     the file's finder icon).
104
105              -transparent
106                     Makes  the  window content area transparent and turns off
107                     the window shadow. For the transparency to  be  effecive,
108                     the  toplevel  background needs to be set to a color with
109                     some alpha, e.g.  “systemTransparent”.
110
111              On X11, the following attributes may be set.  These are not sup‐
112              ported  by  all  window  managers, and will have no effect under
113              older WMs.
114
115              -zoomed
116                     Requests that the window should be  maximized.   This  is
117                     the same as wm state zoomed on Windows and Mac OS X.
118
119              On  X11,  changes  to  window  attributes  are  performed  asyn‐
120              chronously.  Querying the value of an attribute returns the cur‐
121              rent  state,  which  will  not  be  the  same  as the value most
122              recently set if the window manager has  not  yet  processed  the
123              request or if it does not support the attribute.
124
125       wm client window ?name?
126              If  name is specified, this command stores name (which should be
127              the name of the host on which the application is  executing)  in
128              window's  WM_CLIENT_MACHINE  property for use by the window man‐
129              ager or session manager.  The command returns an empty string in
130              this  case.   If  name is not specified, the command returns the
131              last name set in a wm client command for  window.   If  name  is
132              specified   as   an   empty  string,  the  command  deletes  the
133              WM_CLIENT_MACHINE property from window.
134
135       wm colormapwindows window ?windowList?
136              This command is used to manipulate the WM_COLORMAP_WINDOWS prop‐
137              erty,  which  provides  information to the window managers about
138              windows that have private colormaps.
139
140              If windowList is not specified, the command returns a list whose
141              elements are the names of the windows in the WM_COLORMAP_WINDOWS
142              property.  If windowList is specified, it consists of a list  of
143              window  path names;  the command overwrites the WM_COLORMAP_WIN‐
144              DOWS property with  the  given  windows  and  returns  an  empty
145              string.   The  WM_COLORMAP_WINDOWS property should normally con‐
146              tain a list of the internal windows  within  window  whose  col‐
147              ormaps differ from their parents.
148
149              The  order  of  the windows in the property indicates a priority
150              order: the window manager will attempt to install as  many  col‐
151              ormaps  as  possible from the head of this list when window gets
152              the colormap focus.  If window is not included among the windows
153              in  windowList,  Tk implicitly adds it at the end of the WM_COL‐
154              ORMAP_WINDOWS property, so that its colormap is lowest in prior‐
155              ity.   If  wm  colormapwindows is not invoked, Tk will automati‐
156              cally set the property for each  top-level  window  to  all  the
157              internal windows whose colormaps differ from their parents, fol‐
158              lowed by the top-level itself;  the order of the  internal  win‐
159              dows  is undefined.  See the ICCCM documentation for more infor‐
160              mation on the WM_COLORMAP_WINDOWS property.
161
162       wm command window ?value?
163              If value is specified, this command  stores  value  in  window's
164              WM_COMMAND  property  for  use  by the window manager or session
165              manager and returns an empty string.   Value  must  have  proper
166              list  structure;   the  elements should contain the words of the
167              command used to invoke the application.  If value is not  speci‐
168              fied then the command returns the last value set in a wm command
169              command for window.  If value is specified as an  empty  string,
170              the command deletes the WM_COMMAND property from window.
171
172       wm deiconify window
173              Arrange  for  window  to  be displayed in normal (non-iconified)
174              form.  This is done by mapping the window.  If  the  window  has
175              never been mapped then this command will not map the window, but
176              it will ensure that when the window is first mapped it  will  be
177              displayed  in de-iconified form.  On Windows, a deiconified win‐
178              dow will also be raised and be given the focus (made the  active
179              window).  Returns an empty string.
180
181       wm focusmodel window ?active|passive?
182              If  active or passive is supplied as an optional argument to the
183              command, then it specifies the focus model for window.  In  this
184              case  the  command  returns  an  empty string.  If no additional
185              argument is supplied, then the command returns the current focus
186              model for window.
187
188              An  active  focus  model  means that window will claim the input
189              focus for itself or its descendants,  even  at  times  when  the
190              focus  is  currently  in  some other application.  Passive means
191              that window will never claim the focus for itself:   the  window
192              manager  should  give  the focus to window at appropriate times.
193              However, once the focus has been given to window or one  of  its
194              descendants,  the application may re-assign the focus among win‐
195              dow's descendants.  The focus model  defaults  to  passive,  and
196              Tk's focus command assumes a passive model of focusing.
197
198       wm forget window
199              The  window  will be unmapped from the screen and will no longer
200              be managed by wm.  Windows created  with  the  toplevel  command
201              will  be treated like frame windows once they are no longer man‐
202              aged by wm, however, the -menu configuration will be  remembered
203              and the menus will return once the widget is managed again.
204
205       wm frame window
206              If window has been reparented by the window manager into a deco‐
207              rative frame, the command returns the platform  specific  window
208              identifier  for  the  outermost  frame that contains window (the
209              window whose parent is the root or virtual root).  If window has
210              not  been  reparented  by  the  window  manager then the command
211              returns the platform specific window identifier for window.
212
213       wm geometry window ?newGeometry?
214              If newGeometry is specified, then  the  geometry  of  window  is
215              changed  and an empty string is returned.  Otherwise the current
216              geometry for window is returned (this is the most recent  geome‐
217              try specified either by manual resizing or in a wm geometry com‐
218              mand).  NewGeometry has the form =widthxheight±x±y, where any of
219              =,  widthxheight,  or ±x±y may be omitted.  Width and height are
220              positive integers specifying the desired dimensions  of  window.
221              If  window  is  gridded  (see GRIDDED GEOMETRY MANAGEMENT below)
222              then the dimensions are specified in grid units;  otherwise they
223              are specified in pixel units.
224
225              X and y specify the desired location of window on the screen, in
226              pixels.  If x is preceded by +, it specifies the number of  pix‐
227              els  between  the  left  edge of the screen and the left edge of
228              window's border;  if preceded by - then x specifies  the  number
229              of  pixels  between  the  right edge of the screen and the right
230              edge of window's border.  If y is preceded by + then  it  speci‐
231              fies  the number of pixels between the top of the screen and the
232              top of window's border;  if y is preceded by - then it specifies
233              the  number  of pixels between the bottom of window's border and
234              the bottom of the screen.
235
236              If newGeometry is specified as an empty string then any existing
237              user-specified  geometry for window is cancelled, and the window
238              will revert to the size requested internally by its widgets.
239
240       wm grid window ?baseWidth baseHeight widthInc heightInc?
241              This command indicates that window is to be managed as a gridded
242              window.   It  also specifies the relationship between grid units
243              and pixel units.  BaseWidth and baseHeight specify the number of
244              grid  units  corresponding  to  the  pixel  dimensions requested
245              internally by window  using  Tk_GeometryRequest.   WidthInc  and
246              heightInc  specify  the  number of pixels in each horizontal and
247              vertical grid unit.  These four  values  determine  a  range  of
248              acceptable  sizes for window, corresponding to grid-based widths
249              and heights that are non-negative integers.  Tk will  pass  this
250              information  to the window manager;  during manual resizing, the
251              window manager will restrict the window's size to one  of  these
252              acceptable sizes.
253
254              Furthermore, during manual resizing the window manager will dis‐
255              play the window's current size in terms  of  grid  units  rather
256              than  pixels.   If  baseWidth  etc.  are  all specified as empty
257              strings, then window will no longer be managed as a gridded win‐
258              dow.   If  baseWidth etc. are specified then the return value is
259              an empty string.
260
261              Otherwise the return value is a Tcl list  containing  four  ele‐
262              ments   corresponding  to  the  current  baseWidth,  baseHeight,
263              widthInc, and heightInc;  if window is  not  currently  gridded,
264              then an empty string is returned.
265
266              Note:  this  command  should not be needed very often, since the
267              Tk_SetGrid library procedure and the setGrid option provide eas‐
268              ier access to the same functionality.
269
270       wm group window ?pathName?
271              If  pathName is specified, it gives the path name for the leader
272              of a group of related windows.  The window manager may use  this
273              information, for example, to unmap all of the windows in a group
274              when the group's leader is iconified.  PathName may be specified
275              as  an empty string to remove window from any group association.
276              If pathName is specified  then  the  command  returns  an  empty
277              string;   otherwise it returns the path name of window's current
278              group leader, or an empty string if window is not  part  of  any
279              group.
280
281       wm iconbitmap window ?bitmap?
282              If  bitmap  is specified, then it names a bitmap in the standard
283              forms accepted by Tk (see  the  Tk_GetBitmap  manual  entry  for
284              details).   This  bitmap  is  passed to the window manager to be
285              displayed in window's icon, and the  command  returns  an  empty
286              string.   If  an  empty string is specified for bitmap, then any
287              current icon bitmap is cancelled for window.  If bitmap is spec‐
288              ified  then  the  command returns an empty string.  Otherwise it
289              returns the name of the current icon bitmap associated with win‐
290              dow,  or  an  empty string if window has no icon bitmap.  On the
291              Windows operating system, an additional flag is supported:
292
293              wm iconbitmap window ?-default? ?image?
294                     If the -default flag is given, the icon is applied to all
295                     toplevel  windows (existing and future) to which no other
296                     specific icon has yet been applied.  In addition to  bit‐
297                     map  image  types,  a full path specification to any file
298                     which contains a valid  Windows  icon  is  also  accepted
299                     (usually  .ico  or .icr files), or any file for which the
300                     shell has assigned an icon.  Tcl will first test  if  the
301                     file  contains  an icon, then if it has an assigned icon,
302                     and finally, if that fails, test for a bitmap.
303
304       wm iconify window
305              Arrange for window to be iconified.  It window has not yet  been
306              mapped  for  the first time, this command will arrange for it to
307              appear in the iconified state when it is eventually mapped.
308
309       wm iconmask window ?bitmap?
310              If bitmap is specified, then it names a bitmap in  the  standard
311              forms  accepted  by  Tk  (see  the Tk_GetBitmap manual entry for
312              details).  This bitmap is passed to the  window  manager  to  be
313              used as a mask in conjunction with the iconbitmap option:  where
314              the mask has zeroes no icon will be  displayed;   where  it  has
315              ones,  the  bits  from the icon bitmap will be displayed.  If an
316              empty string is specified for bitmap then any current icon  mask
317              is cancelled for window (this is equivalent to specifying a bit‐
318              map of all ones).  If  bitmap  is  specified  then  the  command
319              returns  an  empty string.  Otherwise it returns the name of the
320              current icon mask associated with window, or an empty string  if
321              no mask is in effect.
322
323       wm iconname window ?newName?
324              If  newName  is  specified, then it is passed to the window man‐
325              ager;  the window manager should display newName inside the icon
326              associated  with  window.   In  this  case  an  empty  string is
327              returned as result.  If newName is not specified then  the  com‐
328              mand  returns  the  current  icon  name  for window, or an empty
329              string if no icon name has been specified (in this case the win‐
330              dow  manager will normally display the window's title, as speci‐
331              fied with the wm title command).                                 │
332
333       wm iconphoto window ?-default? image1 ?image2 ...?                      │
334              Sets the titlebar icon for  window  based  on  the  named  photo │
335              images.  If -default is specified, this is applied to all future │
336              created toplevels as well.  The data in the images is taken as a │
337              snapshot  at  the  time  of invocation.  If the images are later │
338              changed, this is not reflected to the titlebar icons.   Multiple │
339              images are accepted to allow different images sizes (e.g., 16x16 │
340              and 32x32) to be provided. The window manager may scale provided │
341              icons to an appropriate size.                                    │
342
343              On Windows, the images are packed into a Windows icon structure. │
344              This will override an ico specified to wm iconbitmap,  and  vice │
345              versa.                                                           │
346
347              On  X, the images are arranged into the _NET_WM_ICON X property, │
348              which most modern window managers support.  A wm iconbitmap  may │
349              exist  simultaneously.  It is recommended to use not more than 2 │
350              icons, placing the larger icon first.                            │
351
352              On Macintosh, this currently does nothing.
353
354       wm iconposition window ?x y?
355              If x and y are specified, they are passed to the window  manager
356              as  a hint about where to position the icon for window.  In this
357              case an empty string is returned.  If x and y are  specified  as
358              empty strings then any existing icon position hint is cancelled.
359              If neither x nor y is specified, then the command returns a  Tcl
360              list  containing two values, which are the current icon position
361              hints (if no hints  are  in  effect  then  an  empty  string  is
362              returned).
363
364       wm iconwindow window ?pathName?
365              If  pathName  is  specified, it is the path name for a window to
366              use as icon for window: when window is iconified  then  pathName
367              will be mapped to serve as icon, and when window is de-iconified
368              then pathName will be unmapped again.  If pathName is  specified
369              as an empty string then any existing icon window association for
370              window will be cancelled.  If the pathName argument is specified
371              then an empty string is returned.  Otherwise the command returns
372              the path name of the current icon window for window, or an empty
373              string  if  there is no icon window currently specified for win‐
374              dow.  Button press events are disabled for window as long as  it
375              is an icon window;  this is needed in order to allow window man‐
376              agers to “own” those events.  Note: not all window managers sup‐
377              port the notion of an icon window.
378
379       wm manage widget
380              The widget specified will become a stand alone top-level window.
381              The window will be decorated with the window managers title bar,
382              etc.  Only  frame,  labelframe  and toplevel widgets can be used
383              with this command. Attempting to pass any other widget type will
384              raise an error. Attempting to manage a toplevel widget is benign
385              and achieves nothing. See also GEOMETRY MANAGEMENT.
386
387       wm maxsize window ?width height?
388              If width and height are specified, they give the maximum permis‐
389              sible dimensions for window.  For gridded windows the dimensions
390              are specified in grid units;  otherwise they  are  specified  in
391              pixel  units.   The  window  manager  will restrict the window's
392              dimensions to be less than or equal to  width  and  height.   If
393              width  and  height  are  specified,  then the command returns an
394              empty string.  Otherwise it returns a Tcl  list  with  two  ele‐
395              ments,  which  are  the  maximum  width  and height currently in
396              effect.  The maximum size defaults to the size  of  the  screen.
397              See  the sections on geometry management below for more informa‐
398              tion.
399
400       wm minsize window ?width height?
401              If width and height are specified, they give the minimum permis‐
402              sible dimensions for window.  For gridded windows the dimensions
403              are specified in grid units;  otherwise they  are  specified  in
404              pixel  units.   The  window  manager  will restrict the window's
405              dimensions to be greater than or equal to width and height.   If
406              width  and  height  are  specified,  then the command returns an
407              empty string.  Otherwise it returns a Tcl  list  with  two  ele‐
408              ments,  which  are  the  minimum  width  and height currently in
409              effect.  The minimum size defaults to one pixel in  each  dimen‐
410              sion.   See  the  sections on geometry management below for more
411              information.
412
413       wm overrideredirect window ?boolean?
414              If boolean is specified, it must have a proper boolean form  and
415              the  override-redirect flag for window is set to that value.  If
416              boolean is not specified then 1 or 0  is  returned  to  indicate
417              whether  or  not the override-redirect flag is currently set for
418              window.  Setting the override-redirect flag for a window  causes
419              it  to  be  ignored  by the window manager;  among other things,
420              this means that the window will not be reparented from the  root
421              window  into a decorative frame and the user will not be able to
422              manipulate the window using the  normal  window  manager  mecha‐
423              nisms.
424
425       wm positionfrom window ?who?
426              If  who  is  specified, it must be either program or user, or an
427              abbreviation of one of these two.  It indicates whether window's
428              current  position  was  requested by the program or by the user.
429              Many window managers ignore program-requested initial  positions
430              and  ask  the  user to manually position the window;  if user is
431              specified then the window manager should position the window  at
432              the  given place without asking the user for assistance.  If who
433              is specified as an  empty  string,  then  the  current  position
434              source  is  cancelled.   If  who  is specified, then the command
435              returns an empty string.  Otherwise it returns user  or  program
436              to  indicate  the source of the window's current position, or an
437              empty string if no source has been specified yet.   Most  window
438              managers  interpret  “no  source”  as equivalent to program.  Tk
439              will automatically set the position source to  user  when  a  wm
440              geometry  command  is  invoked,  unless  the source has been set
441              explicitly to program.
442
443       wm protocol window ?name? ?command?
444              This command is used to manage window manager protocols such  as
445              WM_DELETE_WINDOW.   Name is the name of an atom corresponding to
446              a  window  manager  protocol,  such   as   WM_DELETE_WINDOW   or
447              WM_SAVE_YOURSELF or WM_TAKE_FOCUS.  If both name and command are
448              specified, then command is associated with the  protocol  speci‐
449              fied by name.  Name will be added to window's WM_PROTOCOLS prop‐
450              erty to tell the window manager that the application has a  pro‐
451              tocol  handler  for  name,  and  command  will be invoked in the
452              future whenever the window manager sends a message to the client
453              for  that  protocol.   In this case the command returns an empty
454              string.  If name is specified but command is not, then the  cur‐
455              rent  command  for name is returned, or an empty string if there
456              is no handler defined for name.  If command is specified  as  an
457              empty string then the current handler for name is deleted and it
458              is removed from the WM_PROTOCOLS property on window;   an  empty
459              string  is  returned.   Lastly,  if  neither name nor command is
460              specified, the command returns a list of all the  protocols  for
461              which handlers are currently defined for window.
462
463              Tk  always defines a protocol handler for WM_DELETE_WINDOW, even
464              if  you  have  not  asked  for  one  with  wm  protocol.   If  a
465              WM_DELETE_WINDOW  message  arrives  when  you have not defined a
466              handler, then Tk handles the message by  destroying  the  window
467              for which it was received.
468
469       wm resizable window ?width height?
470              This  command controls whether or not the user may interactively
471              resize a top-level window.  If width and height  are  specified,
472              they  are  boolean  values  that determine whether the width and
473              height of window may be modified by the user.  In this case  the
474              command  returns an empty string.  If width and height are omit‐
475              ted then the command returns a list with two 0/1  elements  that
476              indicate  whether  the  width and height of window are currently
477              resizable.  By default, windows are  resizable  in  both  dimen‐
478              sions.   If resizing is disabled, then the window's size will be
479              the size from the most recent interactive resize or wm  geometry
480              command.   If there has been no such operation then the window's
481              natural size will be used.
482
483       wm sizefrom window ?who?
484              If who is specified, it must be either program or  user,  or  an
485              abbreviation of one of these two.  It indicates whether window's
486              current size was requested by the program or by the user.   Some
487              window  managers ignore program-requested sizes and ask the user
488              to manually size the window;  if user is specified then the win‐
489              dow  manager  should  give the window its specified size without
490              asking the user for assistance.  If who is specified as an empty
491              string,  then  the  current size source is cancelled.  If who is
492              specified, then the command returns an empty string.   Otherwise
493              it returns user or window to indicate the source of the window's
494              current size, or an empty string if no source has been specified
495              yet.   Most  window managers interpret “no source” as equivalent
496              to program.
497
498       wm stackorder window ?isabove|isbelow window?
499              The stackorder command returns a list  of  toplevel  windows  in
500              stacking  order,  from lowest to highest. When a single toplevel
501              window is passed, the returned list recursively includes all  of
502              the  window's  children that are toplevels. Only those toplevels
503              that are currently mapped  to  the  screen  are  returned.   The
504              stackorder command can also be used to determine if one toplevel
505              is positioned above or below a second toplevel.  When two window
506              arguments  separated  by either isabove or isbelow are passed, a
507              boolean result indicates whether or not the first window is cur‐
508              rently above or below the second window in the stacking order.
509
510       wm state window ?newstate?
511              If  newstate  is  specified,  the  window will be set to the new
512              state, otherwise it returns the current state of window:  either
513              normal,  iconic, withdrawn, icon, or (Windows and Mac OS X only)
514              zoomed.  The difference between iconic and icon is  that  iconic
515              refers  to  a  window that has been iconified (e.g., with the wm
516              iconify command) while icon refers to a window whose  only  pur‐
517              pose  is  to serve as the icon for some other window (via the wm
518              iconwindow command).  The icon state cannot be set.
519
520       wm title window ?string?
521              If string is specified, then it will be  passed  to  the  window
522              manager  for  use  as  the  title for window (the window manager
523              should display this string in window's title bar).  In this case
524              the command returns an empty string.  If string is not specified
525              then the command returns the current title for the window.   The
526              title for a window defaults to its name.
527
528       wm transient window ?master?
529              If master is specified, then the window manager is informed that
530              window is a transient window (e.g. pull-down  menu)  working  on
531              behalf  of master (where master is the path name for a top-level
532              window).  If master is specified as an empty string then  window
533              is  marked  as not being a transient window any more.  Otherwise
534              the command returns the path name of window's current master, or
535              an  empty  string if window is not currently a transient window.
536              A transient window will mirror state changes in the  master  and
537              inherit  the state of the master when initially mapped. It is an
538              error to attempt to make a window a transient of itself.
539
540       wm withdraw window
541              Arranges for window to  be  withdrawn  from  the  screen.   This
542              causes the window to be unmapped and forgotten about by the win‐
543              dow manager.  If the window has never  been  mapped,  then  this
544              command  causes  the window to be mapped in the withdrawn state.
545              Not all window managers appear to know  how  to  handle  windows
546              that  are  mapped  in  the  withdrawn state.  Note: it sometimes
547              seems to be necessary to withdraw a window and  then  re-map  it
548              (e.g.  with  wm  deiconify)  to  get some window managers to pay
549              attention to changes in window attributes such as group.
550

GEOMETRY MANAGEMENT

552       By default a top-level window appears on  the  screen  in  its  natural
553       size,  which is the one determined internally by its widgets and geome‐
554       try managers.  If the natural size of a top-level window changes,  then
555       the  window's size changes to match.  A top-level window can be given a
556       size other than its natural size in two  ways.   First,  the  user  can
557       resize  the window manually using the facilities of the window manager,
558       such as resize handles.  Second, the application can request a particu‐
559       lar  size  for a top-level window using the wm geometry command.  These
560       two cases are handled identically by Tk;  in either case, the requested
561       size overrides the natural size.  You can return the window to its nat‐
562       ural by invoking wm geometry with an empty geometry string.
563
564       Normally a top-level window can have any size from one  pixel  in  each
565       dimension  up  to  the size of its screen.  However, you can use the wm
566       minsize and wm maxsize commands to limit the range of allowable  sizes.
567       The  range  set  by  wm  minsize and wm maxsize applies to all forms of
568       resizing, including the window's natural size as well as manual resizes
569       and the wm geometry command.  You can also use the command wm resizable
570       to completely disable interactive resizing in one or both dimensions.
571
572       The wm manage and wm forget commands may be used to  perform  undocking
573       and  docking  of  windows.  After a widget is managed by wm manage com‐
574       mand, all other wm subcommands may be used with the widget.  Only  wid‐
575       gets  created  using the toplevel command may have an attached menu via
576       the -menu configure option.  A toplevel widget may be used as  a  frame
577       and  managed with any of the other geometry managers after using the wm
578       forget command.  Any menu associated with a  toplevel  widget  will  be
579       hidden when managed by another geometry managers.  The menus will reap‐
580       pear once the window is managed by wm.  All custom bindtags for widgets
581       in  a  subtree that have their top-level widget changed via a wm manage
582       or wm forget command, must be redone to  adjust  any  top-level  widget
583       path  in  the  bindtags.  Bindtags that have not been customized do not
584       have to be redone.
585

GRIDDED GEOMETRY MANAGEMENT

587       Gridded geometry management occurs when one of the widgets of an appli‐
588       cation  supports a range of useful sizes.  This occurs, for example, in
589       a text editor where the scrollbars, menus,  and  other  adornments  are
590       fixed  in  size  but the edit widget can support any number of lines of
591       text or characters per line.  In this case, it is usually desirable  to
592       let the user specify the number of lines or characters-per-line, either
593       with the wm geometry command or by interactively resizing  the  window.
594       In the case of text, and in other interesting cases also, only discrete
595       sizes of the window make sense, such as integral numbers of  lines  and
596       characters-per-line;  arbitrary pixel sizes are not useful.
597
598       Gridded  geometry management provides support for this kind of applica‐
599       tion.  Tk (and the window manager) assume that there is a grid of  some
600       sort  within the application and that the application should be resized
601       in terms of grid units rather than pixels.  Gridded geometry management
602       is typically invoked by turning on the setGrid option for a widget;  it
603       can also be invoked with the wm grid command or by calling  Tk_SetGrid.
604       In each of these approaches the particular widget (or sometimes code in
605       the application as a whole) specifies the relationship between integral
606       grid  sizes  for  the window and pixel sizes.  To return to non-gridded
607       geometry management, invoke wm grid with empty argument strings.
608
609       When gridded geometry management is enabled  then  all  the  dimensions
610       specified  in  wm  minsize,  wm  maxsize,  and wm geometry commands are
611       treated as grid units rather than pixel units.  Interactive resizing is
612       also carried out in even numbers of grid units rather than pixels.
613

BUGS

615       Most existing window managers appear to have bugs that affect the oper‐
616       ation of the wm command.  For  example,  some  changes  will  not  take
617       effect  if  the  window  is already active:  the window will have to be
618       withdrawn and de-iconified in order to make the change happen.
619

EXAMPLES

621       A fixed-size window that says that it is fixed-size too:
622              toplevel .fixed
623              wm title     .fixed "Fixed-size Window"
624              wm resizable .fixed 0 0
625
626       A simple dialog-like window, centred on the screen:
627              # Create and arrange the dialog contents.
628              toplevel .msg
629              label  .msg.l  -text "This is a very simple dialog demo."
630              button .msg.ok -text OK -default active -command {destroy .msg}
631              pack .msg.ok -side bottom -fill x
632              pack .msg.l  -expand 1    -fill both
633
634              # Now set the widget up as a centred dialog.
635
636              # But first, we need the geometry managers to finish setting
637              # up the interior of the dialog, for which we need to run the
638              # event loop with the widget hidden completely...
639              wm withdraw .msg
640              update
641              set x [expr {([winfo screenwidth .]-[winfo width .msg])/2}]
642              set y [expr {([winfo screenheight .]-[winfo height .msg])/2}]
643              wm geometry  .msg +$x+$y
644              wm transient .msg .
645              wm title     .msg "Dialog demo"
646              wm deiconify .msg
647

SEE ALSO

649       toplevel(n), winfo(n)
650

KEYWORDS

652       aspect ratio, deiconify, focus  model,  geometry,  grid,  group,  icon,
653       iconify,  increments,  position,  size, title, top-level window, units,
654       window manager
655
656
657
658Tk                                    8.5                                wm(n)
Impressum