A little digital clock

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.

dusthillresident - Wed 13 Mar 20:57:33 GMT 2024

Thanks. When you say that it doesn't run, what do you mean precisely? Is it stopping with an error, and if so, what is the error message? I've tested it on linux with tcl/tk 8.6, and also with windows tclkit 8.6.12 running in Wine, both run and don't report any errors. The windows tclkit didn't display the characters correctly but this might be because I haven't got necessary fonts installed, I need to try on real windows later.

saito - 2024-03-12

I tested it on Windows:

% info patchlevel 8.6.12

The display shows 4 blocks of 4 squares or rectangular looking zeros, separated by colons except the last one which is a dot. The timer does not move. Nothing happens.

If I remove string-map in "every", then it works. So the problem seems to be in whatever encoding convertfrom ... is doing.