Version 2 of A little digital clock

Updated 2024-03-13 14:20:15 by dusthillresident

This is a little digital clock with an LED style display, using unicode characters.

edit: I've now fixed the code so that the wiki site can display it, it seemed to struggle with the unicode symbols used, U+1FBFx from "symbols for legacy computing". See https://en.wikipedia.org/wiki/Box-drawing_character

package require Tk

pack [label .l -font {monospace 26} -background black -foreground red -relief ridge -borderwidth 16] -fill both -expand 1

proc every {ms script} {
 uplevel #0 $script
 after $ms [list every $ms $script]
}

set stringMap {}

for {set i 0} {$i<10} {incr i} {
 lappend stringMap $i [encoding convertfrom utf-8 [binary format H* [string cat {F09FAFB} $i]]]
}

every 44 {
 .l configure -text \
 [string map $stringMap \
  [string cat \
   [clock format [clock seconds] -format {%H:%M:%S.}] \
   [format {%02d } [expr {int([clock milliseconds]%1000/1000.0*100)}]]
  ] \
 ]
}