wm
Gives or sets the properties of a toplevel window: the title, the size, the state, and the hints for the window manager.
wm SUBCOMMAND WINDOW ?ARG ...?
Description
Each subcommand works on WINDOW, which is . or a widget of toplevel. Another widget gives the error window "WINDOW" isn't a top-level window. A subcommand name can be a unique short form, such as ti for title.
A subcommand with an optional value sets the value when the call gives it, and gives the current value when the call does not. Some subcommands are hints of X11 for the window manager, such as wm client or wm iconposition: ztk stores their values and gives them back, with no effect on the window. Each subcommand below says which kind it is.
A close request of the platform, such as a click on the close button, runs the script of wm protocol WINDOW WM_DELETE_WINDOW, or destroys the window when it has no script.
Subcommands
| Subcommand | Description |
|---|---|
wm aspect | Gives or sets the limits of the ratio of width to height of a toplevel. |
wm attributes | Gives or sets the attributes of a toplevel that depend on the platform. |
wm client | Gives or sets the name of the host of the application, for the window manager. |
wm colormapwindows | Gives or sets the widgets with their own colormap, for the window manager. |
wm command | Gives or sets the command that starts the application, for a session manager. |
wm deiconify | Shows a withdrawn or iconified toplevel in its normal state. |
wm focusmodel | Gives or sets the focus model of a toplevel: active or passive. |
wm forget | Makes a toplevel a normal widget, in Tk. |
wm frame | Gives the identifier of the outer frame of a toplevel. |
wm geometry | Gives or sets the size and the position of a toplevel. |
wm grid | Gives or sets the grid of a toplevel, so that its size goes in steps of a cell. |
wm group | Gives or sets the leader of the group of a toplevel. |
wm iconbitmap | Gives or sets a bitmap for the icon of a toplevel. |
wm iconify | Makes a toplevel an icon. |
wm iconmask | Gives or sets a bitmap for the shape of the icon of a toplevel. |
wm iconname | Gives or sets the name under the icon of a toplevel. |
wm iconphoto | Sets the icon of a toplevel from photo images. |
wm iconposition | Gives or sets the place of the icon of a toplevel on the screen. |
wm iconwindow | Gives or sets a widget to show as the icon of a toplevel. |
wm manage | Makes a widget a toplevel, in Tk. |
wm maxsize | Gives or sets the largest size of a toplevel. |
wm minsize | Gives or sets the smallest size of a toplevel. |
wm overrideredirect | Gives or sets whether a toplevel has no title bar and no frame of the window manager. |
wm positionfrom | Gives or sets who asked for the position of a toplevel: program or user. |
wm protocol | Gives or sets the script for a request of the window manager, such as a click on the close button. |
wm resizable | Gives or sets whether the user can change the width and the height of a toplevel. |
wm sizefrom | Gives or sets who asked for the size of a toplevel: program or user. |
wm stackorder | Gives the toplevels in the stacking order, from the bottom to the top. |
wm state | Gives or sets the state of a toplevel: normal, iconic, withdrawn, or zoomed. |
wm title | Gives or sets the title of a toplevel. |
wm transient | Gives or sets the window that a dialog belongs to. |
wm withdraw | Removes a toplevel from the screen. |
Examples
% toplevel .dlg
> wm title .dlg Settings
> wm geometry .dlg 300x200
> update
> list [wm title .dlg] [winfo width .dlg] [winfo height .dlg]
Settings 300 200
Errors
% wm
wrong # args: should be "wm option window ?arg ...?"
-errorcode TCL WRONGARGS
% wm bogus .
bad option "bogus": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw
-errorcode NONE
% frame .f
> wm title .f
window ".f" isn't a top-level window
-errorcode NONE
% wm title .nope
bad window path name ".nope"
-errorcode NONE
Differences from Tcl
- Most errors of
wmhave the-errorcodeNONE. Tk 8.6.16 gives a code such asTCL WRONGARGSorTK LOOKUP TOPLEVEL. - An ambiguous short form of a subcommand gives the error
bad option. Tk 8.6.16 givesambiguous option. wm manageandwm forgethave no effect. In Tk 8.6.16 they make a frame a toplevel, and a toplevel a frame.wm protocolkeeps onlyWM_DELETE_WINDOW. A script for another protocol, such asWM_TAKE_FOCUS, is dropped with no error. Tk 8.6.16 keeps each protocol.wm stackorder WINDOWgives each toplevel of the application, also the toplevels that are withdrawn or outside WINDOW. Tk 8.6.16 gives only the mapped toplevels of WINDOW and of its descendants.wm stackorderwithisaboveorisbelowgives an error. Tk 8.6.16 compares the two windows.wm geometry WINDOW {}keeps the last size of the window. In Tk 8.6.16 the window goes back to its requested size. Also, the requested size of an empty toplevel is 1x1 in ztk, and 200x200 in Tk 8.6.16.- A position from the right or the bottom, such as
-0-0, is given back as+0+0. Tk 8.6.16 keeps-0-0. - ztk does not check the values of
wm aspect,wm grid,wm iconposition,wm iconbitmap,wm positionfrom,wm sizefrom,wm colormapwindows,wm group,wm iconwindow, and of the attributes-alphaand-zoomed. Tk 8.6.16 gives an error for a bad value, such as a value ofwm positionfromthat is notprogramoruser. wm transient WINDOW WINDOWis accepted. Tk 8.6.16 gives the errorsetting "WINDOW" as master creates a transient/master cycle.wm transient,wm focusmodel, andwm overrideredirectwith too many arguments give no error of the count of arguments.wm attributeshas the attributes of X11 on each platform, and-orientationand-zoomof ztk. Tk 8.6.16 has other attributes on Windows and macOS, such as-transparentcolorand-modified.wm state WINDOW zoomedis accepted on each platform. On X11, Tk 8.6.16 gives an error forzoomed.wm iconifyof a window withwm overrideredirect 1gives no error.wm iconphoto WINDOWwith no image gives the images of the last call. Tk 8.6.16 gives an error of the count of arguments.- In Tk 8.6.16 on X11,
-zoomis a short form of-zoomed. In ztk it is its own attribute. wm maxsizehas the default 10000 10000. Tk 8.6.16 gives the size of the screen.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1