4575563 [rkeene@sledge /home/rkeene/projects/tkweb]$ cat -n test1.tk
   1: #!/usr/bin/wish
   2: 
   3: proc buttonA args {
   4: 	set bText [.b cget -text]
   5: 	set aText [.a cget -text]
   6: 	.a configure -text $bText
   7: 	.b configure -text $aText
   8: 	
   9: }
  10: 
  11: proc buttonC args {
  12: 	global joe
  13: 	set joe "${joe}A"
  14: }
  15: 
  16: proc buttonH {sobj dobj} {
  17: 	set text [$sobj get 0.0 end]
  18: 	set output ""
  19: 	foreach word [split $text] {
  20: 		for {set i 0} {$i<[string length $word]} {incr i} {
  21: 			set char [string index $word $i]
  22: 			append output "$char[string tolower $char$char]"
  23: 		}
  24: 		append output " "
  25: 	}
  26: 	$dobj configure -text $output
  27: }
  28: 
  29: proc HandleChange {v i o} {
  30: 	upvar #0 $v lv
  31: 	.jval configure -text "$lv [clock seconds]"
  32: }
  33: 
  34: 
  35: wm title . "Demo #1"
  36: button .a -text "Press Me" -command buttonA
  37: button .b -text "Don't Press Me" -command buttonA
  38: button .c -text "Modify" -command buttonC
  39: entry .d -textvariable joe
  40: label .e -text "Text:"
  41: button .f -text Exit -command exit
  42: text .g
  43: label .i -text ""
  44: button .h -text "Do it" -command "buttonH .g .i"
  45: toplevel .j
  46: button .j.btnClose -text "Close Window" -command { destroy .j }
  47: button .j.btnOkay -text "Accept"
  48: entry .j.entName -textvariable jEntNameVal
  49: label .j.lblName -text "Name:"
  50: label .jval -text "A" 
  51: set joe bob
  52: trace variable jEntNameVal w HandleChange
  53: set jEntNameVal "A"
  54: 
  55: grid configure .a -column 0 -row 0
  56: grid configure .b -column 1 -row 0
  57: grid configure .c -column 0 -row 1
  58: grid configure .e -column 0 -row 2
  59: grid configure .d -column 1 -row 2
  60: grid configure .f -column 0 -row 3 -columnspan 2
  61: grid configure .g -column 0 -row 4 -columnspan 2
  62: grid configure .i -column 0 -row 5 -columnspan 2
  63: grid configure .h -column 0 -row 6 -columnspan 2
  64: grid configure .jval -column 0 -row 7 -columnspan 2
  65: grid configure .j.lblName -column 0 -row 0
  66: grid configure .j.entName -column 1 -row 0
  67: grid configure .j.btnOkay -column 0 -row 1
  68: grid configure .j.btnClose -column 1 -row 1

test1.tk is a simple demo/test program used in the screenshot.
4575564 [rkeene@sledge /home/rkeene/projects/tkweb]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2003-01-27 07:10:26