Version 4 of wm

Updated 2002-02-05 11:31:53

wm - Communicate with window manager. http://purl.org/tcl/home/man/tcl8.4/TkCmd/wm.htm holds the standard documentation.

Please add notes on how you make use of the commands below in useful, and perhaps unique, ways.


  • wm aspect
  • wm client
  • wm colormapwindows
  • wm command
  • wm deiconify
  • wm focusmodel
  • wm frame
  • wm geometry
  • wm grid
  • wm group
  • wm iconbitmap
  • wm iconify
  • wm iconmask
  • wm iconname
  • wm iconposition
  • wm iconwindow
  • wm maxsize
  • wm minsize
  • wm overrideredirect
  • wm positionfrom
  • wm protocol
  • wm resizable
  • wm sizefrom
  • wm state
  • wm title
  • wm transient
  • wm withdraw

wm aspect

This allows you to enforce aspect ratios when resizing a window.

Usage:

 wm aspect . <minAspect> <minDenominator> <maxAspect> <maxDenominator>

The window name must always be specified. The aspect ratios must either be all specifed or all omitted. <minAspect>/<minDenominator> forms the minimum allowed aspect ratio, and <maxAspect>/maxDenominator> forms the maximum allowed aspect ratio.

Examples:

 wm aspect . 4 3 4 3
 wm aspect . 3 2 5 2
 wm aspect .
 wm aspect . "" "" "" ""

wm aspect . 4 3 4 3 will fix the aspect ratio of the window at 4/3. Because the command requires specification of both min and max aspects, it is necessary to specify the aspect twice.

wm aspect . 3 2 5 2 will set the minimum aspect ratio at 3/2, and the maximum at 5/2. When resizing the window, it will be possible to shape it to any aspect ratio that falls between these two ratios.

wm aspect . will return a list of the current aspect settings, or an empty list if there is no aspect ratio currently set.

wm aspect . "" "" "" "" will clear the aspect ratio constraints. Note that since all four numbers must be specified, you actually have to pass the command four empty strings.

Note: This command apparently does not validate its arguments, and it is possible to confuse the window manager somewhat (or severely) if you specify contradictory ratios, or if you specify a smaller max aspect than min aspect.

(Can anyone suggest any practical use for this capability?)

(If anyone in charge of this is paying attention here, how about making it possible to clear the aspect ratio constraints by setting them to zero?)

-EE


Here's a note on wm withdraw from George Petasis in the comp.lang.tcl newsgroup:

I wouldn't advise you to use "wm withdraw ." on the "." window. Under some window managers (especially under unix...) this will prevent dialogs that have as parent the "." (like error messages) to not show up and block your app. Better to use something like:

 wm geometry . 1x1+0+0
 wm overrideredirect . 1
 wm transient .

You can even send it out of the visible part of the screen, like

 wm geometry . 1x1+3000+3000

But in any way do not withdraw it :-)


wm protocol: Use

        wm protocol <window> WM_DELETE_WINDOW {#}

to prevent your window from closing when the [X] button is clicked. More on this subject appears under the title "Catching window managed events".


Could someone address monochrome vs multicolor icons and how to use the appropriate wm command to achieve the difference?


Eric Brunel writes, on news:comp.lang.tcl ,

Since I just spent half an hour to figure out how this works, I thought someone might be interested. The exact syntax is:

 wm iconbitmap <window> <icoFileName>

and not:

 wm iconbitmap <window> @<icoFileName>

(the "regular" bitmap files required the "@" in front of them and the manual is a tad unclear on this point...).


wm iconwindow may not work immediately. Joe English wrote in the comp.lang.tcl newsgroup: You probably just need to unmap and remap the top-level window, so the window manager will notice the changes:

 % wm withdraw .
 % wm state . normal

Tk syntax help - Arts and crafts of Tcl-Tk programming Category Command