WhoAmI? -Gnocl widgets always know who they are

WJG (26/03/08) It's good to see that the Tcl/Tk participation in the Google Summer of Code includes a proposal to implement Gtk rendering of Tk widgets. But GTk is accessible already via the Gnocl package, though it hasn't caught on. What a pity.... But, here's today's offering: A gnocl::widget can use substitution parameters by default to obtain various details; these include its own name.

 #---------------
 # gnoclWhoAmI.tcl
 #---------------
 # Created by William J. Giddings
 # March, 2008
 #---------------
 # Description:
 # In Tcl "..everything is a string". https://wiki.tcl-lang.org/3018
 #---------------
 # Note:
 # The first two widgets created, ie.
 # ::gnocl::_WID1 and ::gnocl::_WID2
 # are the toplevel window and the box container.
 #---------------

 #!/bin/sh/
 #\
 exec tclsh "$0" "[email protected]"
 package require Gnocl

 # create a container
 set box [gnocl::box -buttonType 1 -orientation vertical]
 # add it to a new toplevel
 gnocl::window -title "Buttons" -child $box

 # create a few buttons and return their names
 foreach i {apple bananna cherry damson} {

   # create and pack some buttons
   set tmp [gnocl::button -text "I'm $i\nClick ME!"]

   # gnocl widgets always know who they are!
   $tmp configure -onClicked {puts "I am %w"}
   $box add $tmp

 }