'''`[http://tcl.tk/man/tcl/TkCmd/winfo.htm%|%winfo]`''', a builtin [Tk] [Tk Commands%|%command], returns information about a window. ** See Also ** [wm]: information related to the [Window manager]. ** Common subcommands ** * '''[winfo children]''' ''window'' * '''[winfo class]''' ''window'' * '''[winfo containing]''' ?'''-displayof''' ''window''? ''rootX rootY'' * '''[winfo exists]''' ''window'' * '''[winfo fpixels]''' ''window number'' * '''[winfo geometry]''' ''window'' * '''[winfo height]''' ''window'' * '''[winfo ismapped]''' ''window'' <
> (is ''window'' on the screen?) * '''[winfo manager]''' ''window'' * '''[winfo name]''' ''window'' * '''[winfo parent]''' ''window'' * '''[winfo pixels]''' ''window number'' * '''[winfo pointerx]''' ''window'' * '''[winfo pointerxy]''' ''window'' * '''[winfo pointery]''' ''window'' * '''[winfo reqheight]''' ''window'' * '''[winfo reqwidth]''' ''window'' * '''[winfo rgb]''' ''window color'' * '''[winfo rootx]''' ''window'' * '''[winfo rooty]''' ''window'' * '''[winfo screenheight]''' ''window'' * '''[winfo screenmmheight]''' ''window'' * '''[winfo screenmmwidth]''' ''window'' * '''[winfo screenwidth]''' ''window'' * '''[winfo server]''' ''window'' * '''[winfo toplevel]''' ''window'' * '''[winfo viewable]''' ''window'' * '''[winfo vrootheight]''' ''window'' * '''[winfo vrootwidth]''' ''window'' * '''[winfo vrootx]''' ''window'' * '''[winfo vrooty]''' ''window'' * '''[winfo width]''' ''window'' * '''[winfo x]''' ''window'' * '''[winfo y]''' ''window'' ** Description ** To ensure that the window is fresh, it's usually best to call `winfo` from a script [bind%|%bound] to ``. ** Rarely-used subcommands ** You probably don't need to use these subcommands, either because they couple to functionality that is largely obsolete in the days of universal full-depth displays or because they require deep knowledge of the X protocol to make use of. * '''[winfo atom]''' ?'''-displayof''' ''window''? ''name'' * '''[winfo atomname]''' ?'''-displayof''' ''window''? ''id'' * '''[winfo cells]''' ''window'' * '''[winfo colormapfull]''' ''window'' * '''[winfo depth]''' ''window'' * '''[winfo id]''' ''window'' * '''[winfo interps]''' ?'''-displayof''' ''window''? * '''[winfo pathname]''' ?'''-displayof''' ''window''? ''id'' * '''[winfo screen]''' ''window'' * '''[winfo screencells]''' ''window'' * '''[winfo screendepth]''' ''window'' * '''[winfo screenvisual]''' ''window'' * '''[winfo visual]''' ''window'' * '''[winfo visualid]''' ''window'' * '''[winfo visualsavailable]''' ''window'' ?''includeids''? ** `winfo class` ** [RS] 2006-04-12: '''`winfo class`''' returns for [toplevel%|%toplevels] the app name (as from the topmost script), else the Titlecased [widget] type. Here's a little convenience proc that returns the suitable Tk command for deserializing a widget: ====== proc winfo'class w { if {[winfo toplevel $w] eq $w} {return toplevel} string tolower [winfo class $w] } ====== [MG]: This seems to only be the case for ".". Other toplevels seem to return "Toplevel" as you'd expect. (Anyone know why it returns the app name for ".", though? Curious what the thought behind it was.) [DKF]: It relates to `[option]` database support. In particular, other names would be used by completely different applications (e.g. Firefox, Xterm, etc.) [MG] Ahh, I see. Thanks :) ** The Window Under the Pointer ** [PYK] 2017-05-16: [auriocus] provided this in the [Tcl Chatroom]: ====== # print the window name under the mouse cursor proc pickwin {} { after 1000 { set pickwidget [winfo containing {*}[winfo pointerxy .]] if { $pickwidget ne {} } { puts $pickwidget foreach option [$pickwidget configure] { # leave out synonym options if { [llength $option] != 5 } continue lassign $option name dbname dbclass defvalue currentvalue if { $defvalue != $currentvalue } { puts " $name $currentvalue" } } } else { puts "No widget under cursor." } } } ====== <> Command | Tk syntax help | Arts and Crafts of Tcl-Tk Programming