Posted to tcl by xharx at Thu Mar 04 19:13:06 GMT 2021view raw
- proc buttoncommand {} {
- quit
- destroy .
- }
- proc new {} {
- set done 0
- after 1000 set done 1
- while {! $done} {
- set newtext "foo"
- global ltext
- set ltext $newtext
- update
- }
- set ltext "bar"
- puts $done
- }
- listbox .l1 -width 50 -height 30 -listvariable ltext
- pack .l1
- button .b2 -text "update" -command {new}
- button .b1 -text "ok" -command {quit}
- pack .b1
- pack .b2
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