A little digital clock

Difference between version 2 and 3 - Previous - Next
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)}]]
  ] \
 ]
}
======

----
'''[saito] - 2024-03-12'''

Nice!  However, the code above does not run.  I think it may be related to the unicode stuff. 

BTW, I have a similar version of this with a few customizable options.  Maybe I will try to post it later.