winfo
Gives facts about widgets and the screen: the size, the position, the tree, the class, and the colors.
winfo SUBCOMMAND ?ARG ...?
Description
Each subcommand gives one fact and changes no state. Most subcommands take the name of a widget. The size and the position of a widget come from the last layout, so call update first for the current values. A widget that has had no layout has the size 1x1.
ztk has one display, with a true color visual of 24 bits and 96 pixels for each inch. The subcommands of the colormap, the visuals, and the virtual root of X11 give fixed values. -displayof is accepted where Tk has it, and has no effect.
Subcommands
| Subcommand | Description |
|---|---|
winfo atom | Gives the number of an atom name. |
winfo atomname | Gives the name of an atom number. |
winfo cells | Gives the count of cells in the colormap of a widget. |
winfo children | Gives the child widgets of a widget, in the stacking order. |
winfo class | Gives the class of a widget. |
winfo colormapfull | Gives whether the colormap of a widget is full. |
winfo containing | Gives the widget at a point of the screen. |
winfo depth | Gives the count of bits for each pixel of a widget. |
winfo exists | Gives whether a widget exists. |
winfo fpixels | Gives a screen distance in pixels. |
winfo geometry | Gives the size and the position of a widget, in the form WIDTHxHEIGHT+X+Y. |
winfo height | Gives the height of a widget in pixels. |
winfo id | Gives the identifier of the platform for a widget. |
winfo interps | Gives the names of the applications on the display. |
winfo ismapped | Gives whether a widget is mapped. |
winfo manager | Gives the geometry manager of a widget. |
winfo name | Gives the last part of the path name of a widget. |
winfo parent | Gives the parent of a widget. |
winfo pathname | Gives the widget of an identifier of winfo id. |
winfo pixels | Gives a screen distance in whole pixels. |
winfo pointerx | Gives the x position of the pointer on the screen. |
winfo pointerxy | Gives the x and the y position of the pointer on the screen. |
winfo pointery | Gives the y position of the pointer on the screen. |
winfo reqheight | Gives the height that a widget asks for, in pixels. |
winfo reqwidth | Gives the width that a widget asks for, in pixels. |
winfo rgb | Gives the red, green, and blue values of a color. |
winfo rootx | Gives the x position of the left edge of a widget on the screen. |
winfo rooty | Gives the y position of the top edge of a widget on the screen. |
winfo screen | Gives the name of the screen of a widget. |
winfo screencells | Gives the count of cells in the default colormap of the screen. |
winfo screendepth | Gives the count of bits for each pixel of the screen. |
winfo screenheight | Gives the height of the screen in pixels. |
winfo screenmmheight | Gives the height of the screen in millimeters. |
winfo screenmmwidth | Gives the width of the screen in millimeters. |
winfo screenvisual | Gives the class of the default visual of the screen. |
winfo screenwidth | Gives the width of the screen in pixels. |
winfo server | Gives a description of the display server. |
winfo toplevel | Gives the toplevel that contains a widget. |
winfo viewable | Gives whether a widget and each of its ancestors are mapped. |
winfo visual | Gives the class of the visual of a widget. |
winfo visualid | Gives the identifier of the visual of a widget. |
winfo visualsavailable | Gives the visuals of the screen of a widget. |
winfo vrootheight | Gives the height of the virtual root window of a widget. |
winfo vrootwidth | Gives the width of the virtual root window of a widget. |
winfo vrootx | Gives the x offset of the virtual root window of a widget. |
winfo vrooty | Gives the y offset of the virtual root window of a widget. |
winfo width | Gives the width of a widget in pixels. |
winfo x | Gives the x position of the left edge of a widget in its parent. |
winfo y | Gives the y position of the top edge of a widget in its parent. |
Examples
% frame .f -width 40 -height 30
> pack .f
> update
> list [winfo width .f] [winfo height .f] [winfo manager .f] [winfo class .f]
40 30 pack Frame
Errors
% winfo
wrong # args: should be "winfo option ?arg?"
-errorcode TCL WRONGARGS
% winfo bogus
bad option "bogus": must be cells, children, class, colormapfull, depth, geometry, height, id, ismapped, manager, name, parent, pointerx, pointery, pointerxy, reqheight, reqwidth, rootx, rooty, screen, screencells, screendepth, screenheight, screenwidth, screenmmheight, screenmmwidth, screenvisual, server, toplevel, viewable, visual, visualid, vrootheight, vrootwidth, vrootx, vrooty, width, x, y, atom, atomname, containing, interps, pathname, exists, fpixels, pixels, rgb, or visualsavailable
-errorcode NONE
% winfo ch .
bad option "ch": must be cells, children, class, colormapfull, depth, geometry, height, id, ismapped, manager, name, parent, pointerx, pointery, pointerxy, reqheight, reqwidth, rootx, rooty, screen, screencells, screendepth, screenheight, screenwidth, screenmmheight, screenmmwidth, screenvisual, server, toplevel, viewable, visual, visualid, vrootheight, vrootwidth, vrootx, vrooty, width, x, y, atom, atomname, containing, interps, pathname, exists, fpixels, pixels, rgb, or visualsavailable
-errorcode NONE
Differences from Tcl
- The subcommands need their full names. Tk 8.6.16 accepts a unique short form, such as
chforchildren. - Most errors of
winfohave the-errorcodeNONE, also the error of the count of arguments of a subcommand with one WINDOW. Tk 8.6.16 gives a code such asTCL WRONGARGSorTK LOOKUP WINDOW. winfo atomnamegives the errorno atom exists with idfor each number ofwinfo atom. In Tk 8.6.16,winfo atomname [winfo atom NAME]gives NAME.winfo fpixelsrounds its result to an integer, such as1.0for1.4. Tk 8.6.16 gives the exact value, such as1.3999999999999997.-displayofofwinfo atomandwinfo containingaccepts a name that is not a widget. Tk 8.6.16 gives the errorbad window path name.winfo visualsavailablegives one visual and no identifiers withincludeids, and accepts any word in place ofincludeids. Tk 8.6.16 lists each visual of the X server.winfo pathnamewith an ID that is not a number giveswindow id "ID" doesn't exist in this application. Tk 8.6.16 givesexpected integer but got "ID".winfo servergivesztk, andwinfo pointerxandwinfo pointerygive the position of the last pointer event of the application.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1