I'm not certain what's going on, but running the Tcl after command within a Gnocl application results in the after command not working properly. No big problem. use the gnocl::timeOut command which offers the same basic functionality.
gnocl::timer milliseconds script
returns timerid
To stop a timer, run
gnocl::timer stop timerid
Here's a sample script:
# !/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
set i 0
set hb [gnocl::hBox]
set lab [gnocl::label -variable i -baseFont {Sans 24}]
set stop [gnocl::button -text "STOP" -onClicked {
%w configure -sensitive 0 ; $start configure -sensitive 1
gnocl::timeOut stop $timer } -sensitive 0]
set start [gnocl::button -text "START" -onClicked {
%w configure -sensitive 0 ; $stop configure -sensitive 1
set timer [gnocl::timeOut 1000 { incr i } ] }]
$hb add $lab -fill 1 -expand 1
$hb add "$start $stop"
gnocl::window -title "Timed Counter" -child $hb -width 250
Comments