Tcl/Tk Cookbook - Basics of Tk


Part-II - Step 5: Create bindings to send and reconfigure new values of attributes

Script

Inset in av2 (before the line beginning with tkwait) the lines of script:


proc ValCh {a} { 
	 global aList vList
	 ;# get current index value for a within aList
	 set idx [lsearch $aList $a]
	 set va [.rc.fff.sub$idx.ent get]
      send av [list reJig $va $a]
	}

The procedure ValCh

  1. takes the configure option "a" that the user wishes to change,
  2. gets the new value "va" associated with it,
  3. creates a script line made up of the procedure name reJig, the values of va and a, and sends it to a Tk application named "av" running on the same display as itself to be executed within "av"

Note that this procedure "ValCh" is the script that will be invoked as it is the binding in each entry widget for the event .

New or changed lines of script are highlighted.

Change the value for any of the configuration options and see the result. The following shows the result of setting the background to Red.