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              Note that this is related to winfo geometry, but not  the  same.
241              That  can only query the geometry, and always reflects Tk's cur‐
242              rent understanding of the actual size and  location  of  window,
243              whereas wm geometry allows both setting and querying of the win‐
244              dow manager's understanding of the size and location of the win‐
245              dow.  This  can  vary  significantly, for example to reflect the
246              addition of decorative elements to window such  as  title  bars,
247              and  window  managers  are  not required to precisely follow the
248              requests made through this command.
249
250       wm grid window ?baseWidth baseHeight widthInc heightInc?
251              This command indicates that window is to be managed as a gridded
252              window.   It  also specifies the relationship between grid units
253              and pixel units.  BaseWidth and baseHeight specify the number of
254              grid  units  corresponding  to  the  pixel  dimensions requested
255              internally by window  using  Tk_GeometryRequest.   WidthInc  and
256              heightInc  specify  the  number of pixels in each horizontal and
257              vertical grid unit.  These four  values  determine  a  range  of
258              acceptable  sizes for window, corresponding to grid-based widths
259              and heights that are non-negative integers.  Tk will  pass  this
260              information  to the window manager;  during manual resizing, the
261              window manager will restrict the window's size to one  of  these
262              acceptable sizes.
263
264              Furthermore, during manual resizing the window manager will dis‐
265              play the window's current size in terms  of  grid  units  rather
266              than  pixels.   If  baseWidth  etc.  are  all specified as empty
267              strings, then window will no longer be managed as a gridded win‐
268              dow.   If  baseWidth etc. are specified then the return value is
269              an empty string.
270
271              Otherwise the return value is a Tcl list  containing  four  ele‐
272              ments   corresponding  to  the  current  baseWidth,  baseHeight,
273              widthInc, and heightInc;  if window is  not  currently  gridded,
274              then an empty string is returned.
275
276              Note:  this  command  should not be needed very often, since the
277              Tk_SetGrid library procedure and the setGrid option provide eas‐
278              ier access to the same functionality.
279
280       wm group window ?pathName?
281              If  pathName is specified, it gives the path name for the leader
282              of a group of related windows.  The window manager may use  this
283              information, for example, to unmap all of the windows in a group
284              when the group's leader is iconified.  PathName may be specified
285              as  an empty string to remove window from any group association.
286              If pathName is specified  then  the  command  returns  an  empty
287              string;   otherwise it returns the path name of window's current
288              group leader, or an empty string if window is not  part  of  any
289              group.
290
291       wm iconbitmap window ?bitmap?
292              If  bitmap  is specified, then it names a bitmap in the standard
293              forms accepted by Tk (see  the  Tk_GetBitmap  manual  entry  for
294              details).   This  bitmap  is  passed to the window manager to be
295              displayed in window's icon, and the  command  returns  an  empty
296              string.   If  an  empty string is specified for bitmap, then any
297              current icon bitmap is cancelled for window.  If bitmap is spec‐
298              ified  then  the  command returns an empty string.  Otherwise it
299              returns the name of the current icon bitmap associated with win‐
300              dow,  or  an  empty string if window has no icon bitmap.  On the
301              Windows operating system, an additional flag is supported:
302
303              wm iconbitmap window ?-default? ?image?
304                     If the -default flag is given, the icon is applied to all
305                     toplevel  windows (existing and future) to which no other
306                     specific icon has yet been applied.  In addition to  bit‐
307                     map  image  types,  a full path specification to any file
308                     which contains a valid  Windows  icon  is  also  accepted
309                     (usually  .ico  or .icr files), or any file for which the
310                     shell has assigned an icon.  Tcl will first test  if  the
311                     file  contains  an icon, then if it has an assigned icon,
312                     and finally, if that fails, test for a bitmap.
313
314       wm iconify window
315              Arrange for window to be iconified.  It window has not yet  been
316              mapped  for  the first time, this command will arrange for it to
317              appear in the iconified state when it is eventually mapped.
318
319       wm iconmask window ?bitmap?
320              If bitmap is specified, then it names a bitmap in  the  standard
321              forms  accepted  by  Tk  (see  the Tk_GetBitmap manual entry for
322              details).  This bitmap is passed to the  window  manager  to  be
323              used as a mask in conjunction with the iconbitmap option:  where
324              the mask has zeroes no icon will be  displayed;   where  it  has
325              ones,  the  bits  from the icon bitmap will be displayed.  If an
326              empty string is specified for bitmap then any current icon  mask
327              is cancelled for window (this is equivalent to specifying a bit‐
328              map of all ones).  If  bitmap  is  specified  then  the  command
329              returns  an  empty string.  Otherwise it returns the name of the
330              current icon mask associated with window, or an empty string  if
331              no mask is in effect.
332
333       wm iconname window ?newName?
334              If  newName  is  specified, then it is passed to the window man‐
335              ager;  the window manager should display newName inside the icon
336              associated  with  window.   In  this  case  an  empty  string is
337              returned as result.  If newName is not specified then  the  com‐
338              mand  returns  the  current  icon  name  for window, or an empty
339              string if no icon name has been specified (in this case the win‐
340              dow  manager will normally display the window's title, as speci‐
341              fied with the wm title command).                                 │
342
343       wm iconphoto window ?-default? image1 ?image2 ...?                      │
344              Sets the titlebar icon for  window  based  on  the  named  photo │
345              images.  If -default is specified, this is applied to all future │
346              created toplevels as well.  The data in the images is taken as a │
347              snapshot  at  the  time  of invocation.  If the images are later │
348              changed, this is not reflected to the titlebar icons.   Multiple │
349              images are accepted to allow different images sizes (e.g., 16x16 │
350              and 32x32) to be provided. The window manager may scale provided │
351              icons to an appropriate size.                                    │
352
353              On Windows, the images are packed into a Windows icon structure. │
354              This will override an ico specified to wm iconbitmap,  and  vice │
355              versa.                                                           │
356
357              On  X, the images are arranged into the _NET_WM_ICON X property, │
358              which most modern window managers support.  A wm iconbitmap  may │
359              exist  simultaneously.  It is recommended to use not more than 2 │
360              icons, placing the larger icon first.                            │
361
362              On Macintosh, this currently does nothing.
363
364       wm iconposition window ?x y?
365              If x and y are specified, they are passed to the window  manager
366              as  a hint about where to position the icon for window.  In this
367              case an empty string is returned.  If x and y are  specified  as
368              empty strings then any existing icon position hint is cancelled.
369              If neither x nor y is specified, then the command returns a  Tcl
370              list  containing two values, which are the current icon position
371              hints (if no hints  are  in  effect  then  an  empty  string  is
372              returned).
373
374       wm iconwindow window ?pathName?
375              If  pathName  is  specified, it is the path name for a window to
376              use as icon for window: when window is iconified  then  pathName
377              will be mapped to serve as icon, and when window is de-iconified
378              then pathName will be unmapped again.  If pathName is  specified
379              as an empty string then any existing icon window association for
380              window will be cancelled.  If the pathName argument is specified
381              then an empty string is returned.  Otherwise the command returns
382              the path name of the current icon window for window, or an empty
383              string  if  there is no icon window currently specified for win‐
384              dow.  Button press events are disabled for window as long as  it
385              is an icon window;  this is needed in order to allow window man‐
386              agers to “own” those events.  Note: not all window managers sup‐
387              port the notion of an icon window.
388
389       wm manage widget
390              The widget specified will become a stand alone top-level window.
391              The window will be decorated with the window managers title bar,
392              etc.  Only  frame,  labelframe  and toplevel widgets can be used
393              with this command. Attempting to pass any other widget type will
394              raise an error. Attempting to manage a toplevel widget is benign
395              and achieves nothing. See also GEOMETRY MANAGEMENT.
396
397       wm maxsize window ?width height?
398              If width and height are specified, they give the maximum permis‐
399              sible dimensions for window.  For gridded windows the dimensions
400              are specified in grid units;  otherwise they  are  specified  in
401              pixel  units.   The  window  manager  will restrict the window's
402              dimensions to be less than or equal to  width  and  height.   If
403              width  and  height  are  specified,  then the command returns an
404              empty string.  Otherwise it returns a Tcl  list  with  two  ele‐
405              ments,  which  are  the  maximum  width  and height currently in
406              effect.  The maximum size defaults to the size  of  the  screen.
407              See  the sections on geometry management below for more informa‐
408              tion.
409
410       wm minsize window ?width height?
411              If width and height are specified, they give the minimum permis‐
412              sible dimensions for window.  For gridded windows the dimensions
413              are specified in grid units;  otherwise they  are  specified  in
414              pixel  units.   The  window  manager  will restrict the window's
415              dimensions to be greater than or equal to width and height.   If
416              width  and  height  are  specified,  then the command returns an
417              empty string.  Otherwise it returns a Tcl  list  with  two  ele‐
418              ments,  which  are  the  minimum  width  and height currently in
419              effect.  The minimum size defaults to one pixel in  each  dimen‐
420              sion.   See  the  sections on geometry management below for more
421              information.
422
423       wm overrideredirect window ?boolean?
424              If boolean is specified, it must have a proper boolean form  and
425              the  override-redirect flag for window is set to that value.  If
426              boolean is not specified then 1 or 0  is  returned  to  indicate
427              whether  or  not the override-redirect flag is currently set for
428              window.  Setting the override-redirect flag for a window  causes
429              it  to  be  ignored  by the window manager;  among other things,
430              this means that the window will not be reparented from the  root
431              window  into a decorative frame and the user will not be able to
432              manipulate the window using the  normal  window  manager  mecha‐
433              nisms.
434
435       wm positionfrom window ?who?
436              If  who  is  specified, it must be either program or user, or an
437              abbreviation of one of these two.  It indicates whether window's
438              current  position  was  requested by the program or by the user.
439              Many window managers ignore program-requested initial  positions
440              and  ask  the  user to manually position the window;  if user is
441              specified then the window manager should position the window  at
442              the  given place without asking the user for assistance.  If who
443              is specified as an  empty  string,  then  the  current  position
444              source  is  cancelled.   If  who  is specified, then the command
445              returns an empty string.  Otherwise it returns user  or  program
446              to  indicate  the source of the window's current position, or an
447              empty string if no source has been specified yet.   Most  window
448              managers  interpret  “no  source”  as equivalent to program.  Tk
449              will automatically set the position source to  user  when  a  wm
450              geometry  command  is  invoked,  unless  the source has been set
451              explicitly to program.
452
453       wm protocol window ?name? ?command?
454              This command is used to manage window manager protocols such  as
455              WM_DELETE_WINDOW.   Name is the name of an atom corresponding to
456              a  window  manager  protocol,  such   as   WM_DELETE_WINDOW   or
457              WM_SAVE_YOURSELF or WM_TAKE_FOCUS.  If both name and command are
458              specified, then command is associated with the  protocol  speci‐
459              fied by name.  Name will be added to window's WM_PROTOCOLS prop‐
460              erty to tell the window manager that the application has a  pro‐
461              tocol  handler  for  name,  and  command  will be invoked in the
462              future whenever the window manager sends a message to the client
463              for  that  protocol.   In this case the command returns an empty
464              string.  If name is specified but command is not, then the  cur‐
465              rent  command  for name is returned, or an empty string if there
466              is no handler defined for name.  If command is specified  as  an
467              empty string then the current handler for name is deleted and it
468              is removed from the WM_PROTOCOLS property on window;   an  empty
469              string  is  returned.   Lastly,  if  neither name nor command is
470              specified, the command returns a list of all the  protocols  for
471              which handlers are currently defined for window.
472
473              Tk  always defines a protocol handler for WM_DELETE_WINDOW, even
474              if  you  have  not  asked  for  one  with  wm  protocol.   If  a
475              WM_DELETE_WINDOW  message  arrives  when  you have not defined a
476              handler, then Tk handles the message by  destroying  the  window
477              for which it was received.
478
479       wm resizable window ?width height?
480              This  command controls whether or not the user may interactively
481              resize a top-level window.  If width and height  are  specified,
482              they  are  boolean  values  that determine whether the width and
483              height of window may be modified by the user.  In this case  the
484              command  returns an empty string.  If width and height are omit‐
485              ted then the command returns a list with two 0/1  elements  that
486              indicate  whether  the  width and height of window are currently
487              resizable.  By default, windows are  resizable  in  both  dimen‐
488              sions.   If resizing is disabled, then the window's size will be
489              the size from the most recent interactive resize or wm  geometry
490              command.   If there has been no such operation then the window's
491              natural size will be used.
492
493       wm sizefrom window ?who?
494              If who is specified, it must be either program or  user,  or  an
495              abbreviation of one of these two.  It indicates whether window's
496              current size was requested by the program or by the user.   Some
497              window  managers ignore program-requested sizes and ask the user
498              to manually size the window;  if user is specified then the win‐
499              dow  manager  should  give the window its specified size without
500              asking the user for assistance.  If who is specified as an empty
501              string,  then  the  current size source is cancelled.  If who is
502              specified, then the command returns an empty string.   Otherwise
503              it returns user or window to indicate the source of the window's
504              current size, or an empty string if no source has been specified
505              yet.   Most  window managers interpret “no source” as equivalent
506              to program.
507
508       wm stackorder window ?isabove|isbelow window?
509              The stackorder command returns a list  of  toplevel  windows  in
510              stacking  order,  from lowest to highest. When a single toplevel
511              window is passed, the returned list recursively includes all  of
512              the  window's  children that are toplevels. Only those toplevels
513              that are currently mapped  to  the  screen  are  returned.   The
514              stackorder command can also be used to determine if one toplevel
515              is positioned above or below a second toplevel.  When two window
516              arguments  separated  by either isabove or isbelow are passed, a
517              boolean result indicates whether or not the first window is cur‐
518              rently above or below the second window in the stacking order.
519
520       wm state window ?newstate?
521              If  newstate  is  specified,  the  window will be set to the new
522              state, otherwise it returns the current state of window:  either
523              normal,  iconic, withdrawn, icon, or (Windows and Mac OS X only)
524              zoomed.  The difference between iconic and icon is  that  iconic
525              refers  to  a  window that has been iconified (e.g., with the wm
526              iconify command) while icon refers to a window whose  only  pur‐
527              pose  is  to serve as the icon for some other window (via the wm
528              iconwindow command).  The icon state cannot be set.
529
530       wm title window ?string?
531              If string is specified, then it will be  passed  to  the  window
532              manager  for  use  as  the  title for window (the window manager
533              should display this string in window's title bar).  In this case
534              the command returns an empty string.  If string is not specified
535              then the command returns the current title for the window.   The
536              title for a window defaults to its name.
537
538       wm transient window ?master?
539              If master is specified, then the window manager is informed that
540              window is a transient window (e.g. pull-down  menu)  working  on
541              behalf  of master (where master is the path name for a top-level
542              window).  If master is specified as an empty string then  window
543              is  marked  as not being a transient window any more.  Otherwise
544              the command returns the path name of window's current master, or
545              an  empty  string if window is not currently a transient window.
546              A transient window will mirror state changes in the  master  and
547              inherit  the state of the master when initially mapped. It is an
548              error to attempt to make a window a transient of itself.
549
550       wm withdraw window
551              Arranges for window to  be  withdrawn  from  the  screen.   This
552              causes the window to be unmapped and forgotten about by the win‐
553              dow manager.  If the window has never  been  mapped,  then  this
554              command  causes  the window to be mapped in the withdrawn state.
555              Not all window managers appear to know  how  to  handle  windows
556              that  are  mapped  in  the  withdrawn state.  Note: it sometimes
557              seems to be necessary to withdraw a window and  then  re-map  it
558              (e.g.  with  wm  deiconify)  to  get some window managers to pay
559              attention to changes in window attributes such as group.
560

GEOMETRY MANAGEMENT

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

GRIDDED GEOMETRY MANAGEMENT

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

BUGS

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

EXAMPLES

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

SEE ALSO

659       toplevel(n), winfo(n)
660

KEYWORDS

662       aspect ratio, deiconify, focus  model,  geometry,  grid,  group,  icon,
663       iconify,  increments,  position,  size, title, top-level window, units,
664       window manager
665
666
667
668Tk                                    8.5                                wm(n)
Impressum