1Wm(3) User Contributed Perl Documentation Wm(3)
2
3
4
6 Tk::Wm - Communicate with window manager
7
9 $toplevel->method(?args?)
10
12 The wm methods are used to interact with window managers in order to
13 control such things as the title for a window, its geometry, or the
14 increments in terms of which it may be resized. The wm methods can
15 take any of a number of different forms, depending on the particular
16 method argument. All of the forms expect $toplevel, which must be a
17 top-level window object.
18
19 The legal forms for the wm methods are:
20
21 $toplevel->aspect(?minNumer minDenom maxNumer maxDenom?)
22 If minNumer, minDenom, maxNumer, and maxDenom are all specified,
23 then they will be passed to the window manager and the window man‐
24 ager should use them to enforce a range of acceptable aspect ratios
25 for $toplevel. The aspect ratio of $toplevel (width/length) will
26 be constrained to lie between minNumer/minDenom and maxNumer/maxDe‐
27 nom. If minNumer etc. are all specified as empty strings, then any
28 existing aspect ratio restrictions are removed. If minNumer etc.
29 are specified, then the method returns an empty string. Otherwise,
30 it returns a array containing four elements, which are the current
31 values of minNumer, minDenom, maxNumer, and maxDenom (if no aspect
32 restrictions are in effect, then an empty string is returned).
33
34 $widget->attributes( ?args? );
35 This subcommand returns or sets platform specific attributes
36 associated with a window.
37
38 $widget->attributes;
39 Returns a list of the platform specific flags and their
40 values.
41
42 $widget->attributes( ?option? );
43 Returns the value for the specific option.
44
45 $widget->attributes( ?option value option value...? );
46 Sets one or more of the values. The values are as follows:
47
48 On Windows, -disabled gets or sets whether the window is in
49 a disabled state. -toolwindow gets or sets the style of the
50 window to toolwindow (as defined in the MSDN). -topmost gets
51 or sets whether this is a topmost window (displays above all
52 other win- dows).
53
54 On Macintosh, there are currently no special attribute values.
55
56 On Unix, there are currently no special attribute values.
57
58 $toplevel->client(?name?)
59 If name is specified, this method stores name (which should be the
60 name of the host on which the application is executing) in
61 $toplevel's WM_CLIENT_MACHINE property for use by the window man‐
62 ager or session manager. The method returns an empty string in
63 this case. If name isn't specified, the method returns the last
64 name set in a client method for $toplevel. If name is specified as
65 an empty string, the method deletes the WM_CLIENT_MACHINE property
66 from $toplevel.
67
68 $toplevel->colormapwindows(?windowList?)
69 This method is used to manipulate the WM_COLORMAP_WINDOWS property,
70 which provides information to the window managers about windows
71 that have private colormaps. If windowList isn't specified, the
72 method returns a list whose elements are the names of the windows
73 in the WM_COLORMAP_WINDOWS property. If windowList is specified,
74 it consists of a list of widgets; the method overwrites the WM_COL‐
75 ORMAP_WINDOWS property with the given windows and returns an empty
76 string. The WM_COLORMAP_WINDOWS property should normally contain a
77 list of the internal windows within $toplevel whose colormaps dif‐
78 fer from their parents. The order of the windows in the property
79 indicates a priority order: the window manager will attempt to
80 install as many colormaps as possible from the head of this list
81 when $widget gets the colormap focus. If $widget is not included
82 among the windows in windowList, Tk implicitly adds it at the end
83 of the WM_COLORMAP_WINDOWS property, so that its colormap is lowest
84 in priority. If $widget->colormapwindows is not invoked, Tk will
85 automatically set the property for each top-level window to all the
86 internal windows whose colormaps differ from their parents, fol‐
87 lowed by the top-level itself; the order of the internal windows
88 is undefined. See the ICCCM documentation for more information on
89 the WM_COLORMAP_WINDOWS property.
90
91 $toplevel->command(?value?)
92 If value is specified, this method stores value in $toplevel's
93 WM_COMMAND property for use by the window manager or session man‐
94 ager and returns an empty string. Value must have proper list
95 structure; the elements should contain the words of the command
96 used to invoke the application. If value isn't specified then the
97 method returns the last value set in a command method for
98 $toplevel. If value is specified as an empty string, the method
99 deletes the WM_COMMAND property from $toplevel.
100
101 $toplevel->deiconify
102 Arrange for $toplevel to be displayed in normal (non-iconified)
103 form. This is done by mapping the window. If the window has never
104 been mapped then this method will not map the window, but it will
105 ensure that when the window is first mapped it will be displayed in
106 de-iconified form. Returns an empty string.
107
108 $toplevel->focusmodel(?active⎪passive?)
109 If active or passive is supplied as an optional argument to the
110 method, then it specifies the focus model for $toplevel. In this
111 case the method returns an empty string. If no additional argument
112 is supplied, then the method returns the current focus model for
113 $toplevel. An active focus model means that $toplevel will claim
114 the input focus for itself or its descendants, even at times when
115 the focus is currently in some other application. Passive means
116 that $toplevel will never claim the focus for itself: the window
117 manager should give the focus to $toplevel at appropriate times.
118 However, once the focus has been given to $toplevel or one of its
119 descendants, the application may re-assign the focus among
120 $toplevel's descendants. The focus model defaults to passive, and
121 Tk's focus method assumes a passive model of focusing.
122
123 $toplevel->frame
124 If $widget has been reparented by the window manager into a decora‐
125 tive frame, the method returns the platform specific window identi‐
126 fier for the outermost frame that contains $toplevel (the window
127 whose parent is the root or virtual root). If $toplevel hasn't
128 been reparented by the window manager then the method returns the
129 platform specific window identifier for $toplevel.
130
131 $toplevel->geometry(?newGeometry?)
132 If newGeometry is specified, then the geometry of $toplevel is
133 changed and an empty string is returned. Otherwise the current
134 geometry for $toplevel is returned (this is the most recent geome‐
135 try specified either by manual resizing or in a geometry method).
136 NewGeometry has the form =widthxheight+-x+-y, where any of =,
137 widthxheight, or +-x+-y may be omitted. Width and height are posi‐
138 tive integers specifying the desired dimensions of $toplevel. If
139 $toplevel is gridded (see "GRIDDED GEOMETRY MANAGEMENT" below) then
140 the dimensions are specified in grid units; otherwise they are
141 specified in pixel units. X and y specify the desired location of
142 $toplevel on the screen, in pixels. If x is preceded by +, it
143 specifies the number of pixels between the left edge of the screen
144 and the left edge of $toplevel's border; if preceded by - then x
145 specifies the number of pixels between the right edge of the screen
146 and the right edge of $toplevel's border. If y is preceded by +
147 then it specifies the number of pixels between the top of the
148 screen and the top of $toplevel's border; if y is preceded by -
149 then it specifies the number of pixels between the bottom of
150 $toplevel's border and the bottom of the screen. If newGeometry is
151 specified as an empty string then any existing user-specified geom‐
152 etry for $toplevel is cancelled, and the window will revert to the
153 size requested internally by its widgets.
154
155 $toplevel->wmGrid(?baseWidth,baseHeight,widthInc,heightInc?)
156 This method indicates that $toplevel is to be managed as a gridded
157 window. It also specifies the relationship between grid units and
158 pixel units. BaseWidth and baseHeight specify the number of grid
159 units corresponding to the pixel dimensions requested internally by
160 $toplevel using Tk_GeometryRequest. WidthInc and heightInc specify
161 the number of pixels in each horizontal and vertical grid unit.
162 These four values determine a range of acceptable sizes for
163 $toplevel, corresponding to grid-based widths and heights that are
164 non-negative integers. Tk will pass this information to the window
165 manager; during manual resizing, the window manager will restrict
166 the window's size to one of these acceptable sizes. Furthermore,
167 during manual resizing the window manager will display the window's
168 current size in terms of grid units rather than pixels. If
169 baseWidth etc. are all specified as empty strings, then $toplevel
170 will no longer be managed as a gridded window. If baseWidth etc.
171 are specified then the return value is an empty string. Otherwise
172 the return value is a array containing four elements corresponding
173 to the current baseWidth, baseHeight, widthInc, and heightInc; if
174 $toplevel is not currently gridded, then an empty string is
175 returned. Note: this command should not be needed very often,
176 since the Tk_SetGrid library procedure and the -setgrid option pro‐
177 vide easier access to the same functionality.
178
179 $toplevel->group(?$widget?)
180 If $widget is specified, it is the the leader of a group of related
181 windows. The window manager may use this information, for example,
182 to unmap all of the windows in a group when the group's leader is
183 iconified. $widget may be specified as an empty string to remove
184 $toplevel from any group association. If $widget is specified then
185 the method returns an empty string; otherwise it returns the
186 $toplevel's current group leader, or an empty string if $toplevel
187 isn't part of any group.
188
189 $toplevel->iconbitmap(?bitmap?)
190 If bitmap is specified, then it names a bitmap in the standard
191 forms accepted by Tk (see the Tk_GetBitmap documentation for
192 details). This black and white bitmap is passed to the window man‐
193 ager to be displayed in $toplevel's icon, and the method returns an
194 empty string. If an empty string is specified for bitmap, then any
195 current icon bitmap or image is cancelled for $toplevel. If bitmap
196 is specified then the method returns an empty string. Otherwise it
197 returns the name of the current icon bitmap associated with
198 $toplevel, or an empty string if $toplevel has no icon bitmap.
199
200 $toplevel->iconify
201 Arrange for $toplevel to be iconified. It $toplevel hasn't yet
202 been mapped for the first time, this method will arrange for it to
203 appear in the iconified state when it is eventually mapped.
204
205 $toplevel->iconimage(?image?)
206 If image is specified, then it names a normal Tk image. This image
207 is rendered into a private coloured bitmap which is passed to the
208 window manager to be displayed in $toplevel's icon, and the method
209 returns an empty string. If an empty string is specified for image,
210 then any current icon bitmap or image is cancelled for $toplevel.
211 If image is specified then the method returns an empty string.
212 Otherwise it returns the name of the current icon image associated
213 with $toplevel, or an empty string if $toplevel has no icon image.
214 The private pixmap is not pre-cleared so images which are partly
215 "transparent" display rubbish in their transparent parts.
216
217 The sizes of images that can be used as icons in this manner are
218 platform dependant. On Win32 this sets the "large" icon, which
219 should be 32x32, it will automatically be scaled down to 16x16 for
220 use as a small icon.
221
222 $toplevel->iconmask(?bitmap?)
223 If bitmap is specified, then it names a bitmap in the standard
224 forms accepted by Tk (see the Tk_GetBitmap documentation for
225 details). This bitmap is passed to the window manager to be used
226 as a mask in conjunction with the iconbitmap option: where the
227 mask has zeroes no icon will be displayed; where it has ones, the
228 bits from the icon bitmap will be displayed. If an empty string is
229 specified for bitmap then any current icon mask is cancelled for
230 $toplevel (this is equivalent to specifying a bitmap of all ones).
231 If bitmap is specified then the method returns an empty string.
232 Otherwise it returns the name of the current icon mask associated
233 with $toplevel, or an empty string if no mask is in effect.
234
235 $toplevel->iconname(?newName?)
236 If newName is specified, then it is passed to the window manager;
237 the window manager should display newName inside the icon associ‐
238 ated with $toplevel. In this case an empty string is returned as
239 result. If newName isn't specified then the method returns the
240 current icon name for $toplevel, or an empty string if no icon name
241 has been specified (in this case the window manager will normally
242 display the window's title, as specified with the title method).
243
244 $toplevel->iconphoto(?-default? image1 ?image2 ...?)
245 Sets the titlebar icon for window based on the named photo
246 images. If -default is specified, this is applied to all future
247 created toplevels as well. The data in the images is taken as a
248 snapshot at the time of invocation. If the images are later
249 changed, this is not reflected to the titlebar icons. Multiple
250 images are accepted to allow different images sizes (eg, 16x16
251 and 32x32) to be provided. The window manager may scale pro-
252 vided icons to an appropriate size.
253
254 On Windows, the images are packed into a Windows icon structure.
255 This will override an ico specified to wm iconbitmap, and vice
256 versa. [NOTE: This is not implemented yet!]
257
258 On X, the images are arranged into the _NET_WM_ICON X property,
259 which most modern window managers support. A wm iconbitmap may
260 exist simultaneously. It is recommended to use not more than 2
261 icons, placing the larger icon first.
262
263 On Macintosh, this is currently does nothing.
264
265 $toplevel->iconposition(?x y?)
266 If x and y are specified, they are passed to the window manager as
267 a hint about where to position the icon for $toplevel. In this
268 case an empty string is returned. If x and y are specified as
269 empty strings then any existing icon position hint is cancelled.
270 If neither x nor y is specified, then the method returns a array
271 containing two values, which are the current icon position hints
272 (if no hints are in effect then an empty string is returned).
273
274 $toplevel->iconwindow(?$widget?)
275 If $widget is specified, it is a window to use as icon for
276 $toplevel: when $toplevel is iconified then $widget will be mapped
277 to serve as icon, and when $toplevel is de-iconified then $widget
278 will be unmapped again. If $widget is specified as an empty string
279 then any existing icon window association for $toplevel will be
280 cancelled. If the $widget argument is specified then an empty
281 string is returned. Otherwise the method returns the current icon
282 window for $toplevel, or an empty string if there is no icon window
283 currently specified for $toplevel. Button press events are dis‐
284 abled for $toplevel as long as it is an icon window; this is
285 needed in order to allow window managers to ``own'' those events.
286 Note: not all window managers support the notion of an icon window.
287
288 $toplevel->maxsize(?width,height?)
289 If width and height are specified, they give the maximum permissi‐
290 ble dimensions for $toplevel. For gridded windows the dimensions
291 are specified in grid units; otherwise they are specified in pixel
292 units. The window manager will restrict the window's dimensions to
293 be less than or equal to width and height. If width and height are
294 specified, then the method returns an empty string. Otherwise it
295 returns a array with two elements, which are the maximum width and
296 height currently in effect. The maximum size defaults to the size
297 of the screen. If resizing has been disabled with the resizable
298 method, then this method has no effect. See the sections on geome‐
299 try management below for more information.
300
301 $toplevel->minsize(?width,height?)
302 If width and height are specified, they give the minimum permissi‐
303 ble dimensions for $toplevel. For gridded windows the dimensions
304 are specified in grid units; otherwise they are specified in pixel
305 units. The window manager will restrict the window's dimensions to
306 be greater than or equal to width and height. If width and height
307 are specified, then the method returns an empty string. Otherwise
308 it returns a array with two elements, which are the minimum width
309 and height currently in effect. The minimum size defaults to one
310 pixel in each dimension. If resizing has been disabled with the
311 resizable method, then this method has no effect. See the sections
312 on geometry management below for more information.
313
314 $toplevel->overrideredirect(?boolean?)
315 If boolean is specified, it must have a proper boolean form and the
316 override-redirect flag for $toplevel is set to that value. If
317 boolean is not specified then 1 or 0 is returned to indicate
318 whether or not the override-redirect flag is currently set for
319 $toplevel. Setting the override-redirect flag for a window causes
320 it to be ignored by the window manager; among other things, this
321 means that the window will not be reparented from the root window
322 into a decorative frame and the user will not be able to manipulate
323 the window using the normal window manager mechanisms.
324
325 $toplevel->positionfrom(?who?)
326 If who is specified, it must be either program or user, or an
327 abbreviation of one of these two. It indicates whether $toplevel's
328 current position was requested by the program or by the user. Many
329 window managers ignore program-requested initial positions and ask
330 the user to manually position the window; if user is specified
331 then the window manager should position the window at the given
332 place without asking the user for assistance. If who is specified
333 as an empty string, then the current position source is cancelled.
334 If who is specified, then the method returns an empty string. Oth‐
335 erwise it returns user or $widget to indicate the source of the
336 window's current position, or an empty string if no source has been
337 specified yet. Most window managers interpret ``no source'' as
338 equivalent to program. Tk will automatically set the position
339 source to user when a geometry method is invoked, unless the source
340 has been set explicitly to program.
341
342 $toplevel->protocol(?name?,?callback?)
343 This method is used to manage window manager protocols such as
344 WM_DELETE_WINDOW. Name is the name of an atom corresponding to a
345 window manager protocol, such as WM_DELETE_WINDOW or WM_SAVE_YOUR‐
346 SELF or WM_TAKE_FOCUS. If both name and callback are specified,
347 then callback is associated with the protocol specified by name.
348 Name will be added to $toplevel's WM_PROTOCOLS property to tell the
349 window manager that the application has a protocol handler for
350 name, and callback will be invoked in the future whenever the win‐
351 dow manager sends a message to the client for that protocol. In
352 this case the method returns an empty string. If name is specified
353 but callback isn't, then the current callback for name is returned,
354 or an empty string if there is no handler defined for name. If
355 callback is specified as an empty string then the current handler
356 for name is deleted and it is removed from the WM_PROTOCOLS prop‐
357 erty on $toplevel; an empty string is returned. Lastly, if nei‐
358 ther name nor callback is specified, the method returns a list of
359 all the protocols for which handlers are currently defined for
360 $toplevel.
361
362 Tk always defines a protocol handler for WM_DELETE_WINDOW,
363 even if you haven't asked for one with protocol. If a
364 WM_DELETE_WINDOW message arrives when you haven't defined a
365 handler, then Tk handles the message by destroying the win‐
366 dow for which it was received.
367
368 $toplevel->resizable(?width,height?)
369 This method controls whether or not the user may interactively
370 resize a top-level window. If width and height are specified, they
371 are boolean values that determine whether the width and height of
372 $toplevel may be modified by the user. In this case the method
373 returns an empty string. If width and height are omitted then the
374 method returns a list with two 0/1 elements that indicate whether
375 the width and height of $toplevel are currently resizable. By
376 default, windows are resizable in both dimensions. If resizing is
377 disabled, then the window's size will be the size from the most
378 recent interactive resize or geometry method. If there has been no
379 such operation then the window's natural size will be used.
380
381 $toplevel->sizefrom(?who?)
382 If who is specified, it must be either program or user, or an
383 abbreviation of one of these two. It indicates whether $toplevel's
384 current size was requested by the program or by the user. Some
385 window managers ignore program-requested sizes and ask the user to
386 manually size the window; if user is specified then the window
387 manager should give the window its specified size without asking
388 the user for assistance. If who is specified as an empty string,
389 then the current size source is cancelled. If who is specified,
390 then the method returns an empty string. Otherwise it returns user
391 or $widget to indicate the source of the window's current size, or
392 an empty string if no source has been specified yet. Most window
393 managers interpret ``no source'' as equivalent to program.
394
395 $toplevel->stackorder( ?isabove⎪isbelow $toplevel? );
396 The stackorder command returns a list of toplevel windows in
397 stacking order, from lowest to highest. When a single toplevel
398 window is passed, the returned list recursively includes all of
399 the window's children that are toplevels. Only those toplevels
400 that are currently mapped to the screen are returned. The
401 stackorder command can also be used to determine if one toplevel is
402 positioned above or below a second toplevel. When two window argu‐
403 ments separated by either isabove or isbelow are passed, a bool‐
404 ean result indicates whether or not the first window is currently
405 above or below the second window in the stacking order.
406
407 $toplevel->state(?newstate?)
408 If newstate is specified, the window will be set to the new state,
409 otherwise it returns the current state of $toplevel: either normal,
410 iconic, withdrawn, icon, or (Windows only) zoomed. The difference
411 between iconic and icon is that iconic refers to a window that has
412 been iconified (e.g., with the iconify method) while icon refers to
413 a window whose only purpose is to serve as the icon for some other
414 window (via the iconwindow method). The icon state cannot be set.
415
416 $toplevel->title(?string?)
417 If string is specified, then it will be passed to the window man‐
418 ager for use as the title for $toplevel (the window manager should
419 display this string in $toplevel's title bar). In this case the
420 method returns an empty string. If string isn't specified then the
421 method returns the current title for the $toplevel. The title for
422 a window defaults to its name.
423
424 $toplevel->transient(?master?)
425 If master is specified, then the window manager is informed that
426 $toplevel is a transient window (e.g. pull-down menu) working on
427 behalf of master (where master is a top-level window). Some window
428 managers will use this information to manage $toplevel specially.
429 If master is specified as an empty string then $toplevel is marked
430 as not being a transient window any more. If master is specified,
431 then the method returns an empty string. Otherwise the method
432 returns the path name of $toplevel's current master, or an empty
433 string if $toplevel isn't currently a transient window.
434
435 $toplevel->withdraw
436 Arranges for $toplevel to be withdrawn from the screen. This
437 causes the window to be unmapped and forgotten about by the window
438 manager. If the window has never been mapped, then this method
439 causes the window to be mapped in the withdrawn state. Not all
440 window managers appear to know how to handle windows that are
441 mapped in the withdrawn state. Note: it sometimes seems to be nec‐
442 essary to withdraw a window and then re-map it (e.g. with
443 deiconify) to get some window managers to pay attention to changes
444 in window attributes such as group.
445
446 $toplevel->wrapper
447 Returns the window id of the wrapper window in which Tk has placed
448 $toplevel. This is the id by which window manager will know
449 $toplevel, and so is appropriate place to add X properties.
450
452 The sizes of bitmaps/images that can be used as icons in this manner
453 are platform and window manager dependant. Unix window managers are
454 typically more tolerant than Win32. It is possible that coloured "icon‐
455 image" icons may cause problems on some X window managers.
456
457 * Win32
458 "iconimage" and "iconbitmap" set the "large" icon, which should be
459 32x32, it will automatically be scaled down to 16x16 for use as a
460 small icon. Win32 ignores "iconwin" requests.
461
462 * KDE's "kwm"
463 Accepts coloured "iconimage" and black and white "iconbitmap" but
464 will scale either to a small (14x14?) icon. Kwm ignores "iconwin".
465
466 * Sun's "olwm" or "olvwm"
467 Honours "iconwin" which will override "iconimage" or "iconbitmap".
468 Coloured images work.
469
470 * Sun's CDE window manager
471 Coloured images work. ...
472
474 By default a top-level window appears on the screen in its natural
475 size, which is the one determined internally by its widgets and geome‐
476 try managers. If the natural size of a top-level window changes, then
477 the window's size changes to match. A top-level window can be given a
478 size other than its natural size in two ways. First, the user can
479 resize the window manually using the facilities of the window manager,
480 such as resize handles. Second, the application can request a particu‐
481 lar size for a top-level window using the geometry method. These two
482 cases are handled identically by Tk; in either case, the requested
483 size overrides the natural size. You can return the window to its nat‐
484 ural by invoking geometry with an empty geometry string.
485
486 Normally a top-level window can have any size from one pixel in each
487 dimension up to the size of its screen. However, you can use the min‐
488 size and maxsize methods to limit the range of allowable sizes. The
489 range set by minsize and maxsize applies to all forms of resizing,
490 including the window's natural size as well as manual resizes and the
491 geometry method. You can also use the method resizable to completely
492 disable interactive resizing in one or both dimensions.
493
495 Gridded geometry management occurs when one of the widgets of an appli‐
496 cation supports a range of useful sizes. This occurs, for example, in
497 a text editor where the scrollbars, menus, and other adornments are
498 fixed in size but the edit widget can support any number of lines of
499 text or characters per line. In this case, it is usually desirable to
500 let the user specify the number of lines or characters-per-line, either
501 with the geometry method or by interactively resizing the window. In
502 the case of text, and in other interesting cases also, only discrete
503 sizes of the window make sense, such as integral numbers of lines and
504 characters-per-line; arbitrary pixel sizes are not useful.
505
506 Gridded geometry management provides support for this kind of applica‐
507 tion. Tk (and the window manager) assume that there is a grid of some
508 sort within the application and that the application should be resized
509 in terms of grid units rather than pixels. Gridded geometry management
510 is typically invoked by turning on the setGrid option for a widget; it
511 can also be invoked with the wmGrid method or by calling Tk_SetGrid.
512 In each of these approaches the particular widget (or sometimes code in
513 the application as a whole) specifies the relationship between integral
514 grid sizes for the window and pixel sizes. To return to non-gridded
515 geometry management, invoke grid with empty argument strings.
516
517 When gridded geometry management is enabled then all the dimensions
518 specified in minsize, maxsize, and geometry methods are treated as grid
519 units rather than pixel units. Interactive resizing is also carried
520 out in even numbers of grid units rather than pixels.
521
523 Most existing window managers appear to have bugs that affect the oper‐
524 ation of the wm methods. For example, some changes won't take effect
525 if the window is already active: the window will have to be withdrawn
526 and de-iconified in order to make the change happen.
527
529 Tk::Widget Tk::tixWm Tk::Mwm
530
532 aspect ratio, deiconify, focus model, geometry, grid, group, icon,
533 iconify, increments, position, size, title, top-level window, units,
534 window manager
535
536
537
538perl v5.8.8 2008-02-05 Wm(3)