Skip to main content

Posts

Showing posts from August, 2021

gnocl::timeOut

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

Working with tagging words.

The problem, how to tag a block of text in a textwidget when only a row-col (line-offset) pairing is know? The Gnocl text widget has employed offsets for some time but this has always been in used in commands where the insertion point is used. Some recent changes to the getPos text subcommand will go some way in picking out words, lines etc., when using the "tag apply" instruction.  Previously, getPos would only return a line-offset pair based upon the current mouse pointer position over the widget, this has now become the default. The enhancements allow two arguments to be passed, a line-offset pair and a keyword. So, if the line-offset refers to a point mid-way in a word, its now possible to hold of other relative positions using keywords.   $text tag apply \ [$text getPos [list $a $b] wordStart] \ [$text getPos [list $a $b] wordEnd] \ -tags red