Tk::find
The commnd Tk::find is used for
locate widgets. Its signature is:
proc find {{window .} {name *} {class *} {script {}}}
It finds windows from the start window for which
[winfo name] and [winfo class] match the
given patterns.
If script is empty it just return the matching windows.
If script is non-empty it is eval'ed on each match,
after the window name is substituted for %W in the script.
eg:
frame .f
text .f.mainwin
entry .f.status
entry .f.input
Tk::find . mainwin; # returns ".f.mainwin"
Tk::find . * Entry; # return ".f.status .f.input"
Tk::find .f in* Entry; # return ".f.input"
Tk::find .x * Entry { puts "DESTROY: %W"; destroy %W }
Note that calling Tk::find with no arguments
will just return a list of all windows.
© 2008 Peter MacDonald