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