Posted to tcl by xharx at Thu Mar 04 20:05:35 GMT 2021view raw

  1.  
  2. proc buttoncommand {} {
  3. quit
  4. destroy .
  5. }
  6.  
  7. proc new {} {
  8. global done
  9. set done 0
  10. after 1000 set done 1
  11. while {! $done} {
  12. set newtext "foo"
  13. global ltext
  14. set ltext $newtext
  15. update
  16. }
  17. set ltext "bar"
  18. puts $done
  19. }
  20.  
  21. proc new2 {} {
  22. set done 0;
  23. after 1000 {set done 1}
  24. set ::ltext2 1
  25. proc handler {} {
  26. incr ::ltext2
  27. set ::ev
  28. [after 10 handler]
  29. }
  30. handler vwait done
  31. after cancel $::ev
  32. set ::ltext "done"
  33. }
  34.  
  35. listbox .l1 -width 50 -height 10 -listvariable ltext
  36. pack .l1
  37. listbox .l2 -width 50 -height 10 -listvariable ::ltext2
  38. pack .l2
  39. button .b1 -text "ok" -command {quit}
  40. button .b2 -text "update" -command {new}
  41. button .b3 -text "update2" -command {new2}
  42. pack .b1
  43. pack .b2
  44. pack .b3
  45.  
  46.  
  47.