Posted to tcl by xharx at Thu Mar 04 19:13:06 GMT 2021view raw

  1.  
  2. proc buttoncommand {} {
  3. quit
  4. destroy .
  5. }
  6.  
  7. proc new {} {
  8. set done 0
  9. after 1000 set done 1
  10. while {! $done} {
  11. set newtext "foo"
  12. global ltext
  13. set ltext $newtext
  14. update
  15. }
  16. set ltext "bar"
  17. puts $done
  18. }
  19.  
  20. listbox .l1 -width 50 -height 30 -listvariable ltext
  21. pack .l1
  22. button .b2 -text "update" -command {new}
  23. button .b1 -text "ok" -command {quit}
  24. pack .b1
  25. pack .b2
  26.  
  27.  
  28.  

Comments

Posted by sebres at Thu Mar 04 19:42:15 GMT 2021 [text] [code]

proc new {} { set done 0; after 1000 {set done 1} set ::ltext 1 proc handler {} { incr ::ltext set ::ev [after 10 handler] } handler vwait done after cancel $::ev set ::ltext "done" } listbox .l1 -width 50 -height 30 -listvariable ::ltext pack .l1 button .b2 -text "update" -command {new} pack .b2

Posted by sebres at Thu Mar 04 20:01:29 GMT 2021 [text] [code]

proc next {} { incr ::ltext set ::ev [after 10 next] } proc start {} { puts start:\t$::ltext if {![string is integer -strict $::ltext]} { set ::ltext 1 } next } proc stop {} { puts stop:\t$::ltext after cancel $::ev } listbox .l1 -width 50 -height 30 -listvariable ::ltext button .b1 -text "start" -command {start} button .b2 -text "stop" -command {stop} pack .l1 .b1 .b2