if 0 {
MiHa 2015-02-24 - A fuzzy clock shows approximate time only, that is, with a precision of a few minutes.
For example, for any time between 03:08 and 03:12 you would get a string like "Ten minutes past three o'clock",
There are already some programs that do that, examples are:
My fuzzy clock doesn't output a string, it highlights fixed panels with a list of words on them,
like turning on lamps inside panels which have a cover labeled with one of those words.
Some inspiration came from the following programs and pages here :
Other programs that are doing something with time:
Example: looking for "create text" - the search shows lots of hits, but the page I want
turns out to be Tk Built-In Commands - canvas manual .
That is far from obvious.
And on that page, the thing I wanted is pathName create type ... ,
where type can be arc, bitmap, line, rect ... and, after scrolling almost all the way down, also text.
That was not the most helpful way to present the information.
In fact, I can hardly imagine the noob that would make it so far.
I think this is a serious obstacle for newcomers.
For a reference-manual this might be ok, but when looking for help to get something done, this is not enough.
Helpful people on IRC are nice to have, but shouldn't be a substitute for good docs.
And examples are also very much missing in that helpfile.
I would expect links to lots of short, self-contained, working snippets of code included in such a helpfile.
}
# FuzzyClock64.tcl - Mike Hase - 2015-02-24 / 2015-03-13 # http://wiki.tcl.tk/41162 package require Tk set Prog(title) "FuzzyClock" set Prog(version) "v1.01" set Prog(date) "2015-03-14" set Prog(options) "" set scX 12 ### Colortable: (ToDo) set Co(bg) grey #set bg white set bg grey set ol black set hi1 cyan set hi2 yellow set tx1 blue set tx2 white set hiC $hi1 set txC $tx1 ### Display: proc makeText {w tag name rectCoords} { global scX set id1 [$w create rect $rectCoords -tag $tag -fill $::bg -outline $::ol] foreach {x y} $rectCoords break incr x incr y set id2 [$w create text $x $y -tag t$tag -anchor w -text $name] $w addtag time withtag $tag $w addtag txt withtag t$tag # puts "$id1 $id2 : $x $y $tag $name" ;## ##$w scale $id1 0 0 12 15 ##$w scale $id2 0 0 12 15 $w scale $id1 0 0 $scX 15 $w scale $id2 0 0 $scX 15 } proc reset {tag} { foreach id [ .c find withtag time] { .c itemconfigure $id -fill $::bg } foreach id [ .c find withtag txt ] { .c itemconfigure $id -fill black } } proc hi {tag} { foreach id [ .c find withtag $tag ] { .c itemconfigure $id -fill $::hiC } foreach id [ .c find withtag t$tag ] { .c itemconfigure $id -fill $::txC } } ### Update display: proc upd_fc {} { # update for fuzzyclock: global cs td hh ii mm am wd tH tM tA mTab sTab set tH "t_$ii" set tA "t_$am" #puts "$ii / $tH $tA" ;## set tM "$mm" #puts "$tM" ;## set i 0 #puts "$tM : mTab($tM) -->" ;## foreach t $mTab($tM) { #incr i; puts " $i. $t"; hi $t if { $t=="hH" } { ;# show next hour incr ii; if { $ii>=13 } { set ii 1 } ;# max. 12 o'clock #puts "++ii: $ii" } } set tH "t_$ii" #puts "++ $tH $tA" ;## hi $tH foreach t $mTab($mm) { #incr i; puts " $i. $t" ;## hi $t } hi t_C hi $tA } proc upd_sc {} { # update for shipclock: global cs td hh ii mm am wd tH tM tA mTab sTab set shiptags "t_gI " set ww [watch $hh $mm] set W $sTab($ww) #puts "ww $ww : $W ==>" ;## foreach t $W { #incr i; puts " $i. $t" ;## hi $t } set gg [bells $ii $mm] puts "Ship: $hh h $mm m => watch $ww, $gg glasen/bells" ;## if { $gg == "1" } { append shiptags "t_g1 " } if { $gg == "2" } { append shiptags "t_g2 " } if { $gg == "3" } { append shiptags "t_g3 " } if { $gg == "4" } { append shiptags "t_g4 " } if { $gg == "5" } { append shiptags "t_g5 " } if { $gg == "6" } { append shiptags "t_g6 " } if { $gg == "7" } { append shiptags "t_g7 " } if { $gg == "8" } { append shiptags "t_g8 " } #puts "$cs> $hh $ii : $mm - $wd" ;## ### Demo for ship's bell: #hi t_gI; hi t_HN; hi t_g2 if { $::wd == 0 } { append shiptags "t_Su " } if { $::hh==12 && $::mm== 0 } { append shiptags "t_HN " } set mm3 [s2i $mm] if {$mm3>=30} {incr mm3 -30} set gm "0" # find nearest matching minute-entry in sTab: for {set m 0} {$m<30} {incr m} { if { [info exists sTab($m)] } { set gm $m } #puts ".. $m -> $gm" ;## if {$m>=$mm3} {break} } #puts "!! $mm $m -> <<$sTab($gm)>> $gm" append shiptags $sTab($gm) puts "$hh:$mm $mm3 $gm ---> $shiptags " ;## set i 0 foreach t $shiptags { #incr i; puts "Ship: $i. $t" ;## hi $t } } proc upd {} { global cs td hh ii mm am wd #wm title . "$td" #wm title . "$td / $ii:$mm $am" wm title . "($::fc) $td / $ii:$mm $am" if { $::fc == "G" || $::fc == "SB" } { upd_sc } else { upd_fc } } proc u {} { reset time reset txt upd if { $::hiC==$::hi1 } { set ::hiC yellow } else { set ::hiC cyan } ;# change colors } ### Test+Debug: proc ? {} { help } proc help {} { puts "argv0 : $::argv0" puts "argv : $::argv" puts "tcl/tk: $::tcl_patchLevel / $::tk_patchLevel" puts "now,t,h,m,x,y:change time, u:update, run,stop, p,p1,p2,pp:pos, bg:color, e:exit" } # Note: testing might be easier by changing the system-clock proc t1 {} { set ::cs [clock scan {2015-03-13 23:55:00} -format {%Y-%m-%d %H:%M:%S}] } proc t {} { set ::cs [clock scan {09:55:00} -format {%H:%M:%S}] } proc x {} { set ::mm "10" } proc y {} { set ::ii "12"; set ::mm "02" } proc h {} { incr ::ii } proc m {} { incr ::mm } # screen+color / find window for active console: proc bg { {c HotPink} } { .c configure -background $c; #wm deiconify . } # screen+position: proc p {} { puts "wm geom . : [wm geom .]" } proc pp {} { wm geom . +740+20; wm deiconify . ; p } proc p1 {} { wm geom . +1+1; wm deiconify . ; p } proc p2 {} { wm geom . +740+1; wm deiconify . ; p } proc e {} { exit } ### Misc / Utility: proc s2i {s} { ;# string-to-int / workaround for problem converting "08" and "09" ##puts ">>>$s<<<" #incr s 0 #set i $s #format %u $s if { $s == "08" } { set s " 8" } ;# !! workaround !! if { $s == "09" } { set s " 9" } set i [expr {$s}] } proc c1 {s} { set char1 [string range $s 0 0 ] } ;# return first char proc c9 {s} { set char9 [string range $s end end ] } ;# return last char ### Ship's bell: proc b1 {} { bell } proc b2 {} { bell; after 250; bell; after 400 } proc ringbell { {b 1} } { puts "RingBell>>>$b<<< mm=$::mm sound=$::sound\n" if { $::sound == 0 } { return } if { $::sound == 1 } { if { $::mm == "00"} { bell } return } # sound==2 : Ship's bell: while { $b>=2 } { b2; incr b -2 } while { $b>=1 } { b1; incr b -1 } } proc watch {hh mm} { set ww 0 if { $hh=="00" || $hh=="01" || $hh=="02" || $hh=="03" } { set ww "w0" } if { $hh=="04" || $hh=="05" || $hh=="06" || $hh=="07" } { set ww "w1" } if { $hh=="08" || $hh=="09" || $hh=="10" || $hh=="11" } { set ww "w2" } if { $hh=="12" || $hh=="13" || $hh=="14" || $hh=="15" } { set ww "w3" } if { $hh=="16" || $hh=="17" || $hh=="18" || $hh=="19" } { set ww "w4" } if { $hh=="20" || $hh=="21" || $hh=="22" || $hh=="23" } { set ww "w5" } #puts "watch>>>$hh:$mm>> $ww" ;## return $ww } proc bells {hh mm} { set bb 0 set hh [s2i $hh] if { $hh== 1 || $hh== 5 || $hh== 9 } { set bb 2 } if { $hh== 2 || $hh== 6 || $hh==10 } { set bb 4 } if { $hh== 3 || $hh== 7 || $hh==11 } { set bb 6 } if { $hh== 4 || $hh== 8 || $hh==12 } { set bb 8 } if { $mm >= 30 } { incr bb } if { $bb >= 9 } { set bb 1 } ;# max. 8 bells/glasen #puts "bells>>>$hh:$mm>>$bb" ;## return $bb } ### Time: proc now { {t -1} } { global cs td hh ii mm am wd tH tM tA mTab if { $t<0 } { set cs [clock seconds] } else { set cs $t } set td [clock format $cs -format "%H:%M:%S - %l:%M %p" ] set hh [clock format $cs -format "%H" ] set ii [clock format $cs -format "%l" ] ;# %I %k %l set mm [clock format $cs -format "%M" ] set ss [clock format $cs -format "%S" ] set am [clock format $cs -format "%p" ] set wd [clock format $cs -format "%w" ] ;# 0=Sunday if { $am=="PM" && $hh<"18"} { set am "_" } ;# no "PM" before 18:00 set ii [s2i $ii] if { $ii>=13 } { set ii 1 } ;# max. 12 o'clock puts "$hh:$mm:$ss -> $ii:$mm $am" ;## set s1 [c1 $ss] if { $mm=="00" && $s1=="0"} { ringbell [bells $ii $mm] } if { $mm=="30" && $s1=="0"} { ringbell [bells $ii $mm] } } ### Time/Repeat/Wait: proc every {ms body} { if 1 $body after $ms [list after idle [info level 0]] } proc stop {} {foreach id [after info] {after cancel $id}; } proc run0 {} {every 10000 {now; u} } proc run {} {now; u; sync2 } proc sync0 {} { # Wait until seconds reach a multiple of 10. # Problem: makes the program unresponsive during the first few seconds. update for {set i 1} {$i<=30} {incr i} { set ::cs [clock seconds] set s0 [expr $::cs % 10] puts "sync0: $i $::cs $s0" ;## if { $s0 == 0 } { break } after 333 } } proc sync2 {} { # adjust time for re-scheduling, to get closer to a time # with the seconds at a multiple of 10. set ::cs [clock seconds] set s0 [expr $::cs % 10] if { $s0 == 0 } { after 10000 run; #puts "sync2: $::td $::cs $s0 #==ok==" ;## } else { after 9000 run; #puts "sync2: $::td $::cs $s0 #++adjust++" ;## } } ### Positions, spreadsheet-style: # see also scale #set a1 { 1 1 4 3 } #set b1 { 4 1 7 3 } #set c1 { 7 1 10 3 } set a1 { 1 1 8 3 } set b1 { 8 1 14 3 } set c1 { 14 1 21 3 } set a2 { 1 3 8 5 } set b2 { 8 3 14 5 } set c2 { 14 3 21 5 } set a3 { 1 5 8 7 } set b3 { 8 5 14 7 } set c3 { 14 5 21 7 } set a4 { 1 7 8 9 } set b4 { 8 7 14 9 } set c4 { 14 7 21 9 } set a5 { 1 9 8 11 } set b5 { 8 9 14 11 } set c5 { 14 9 21 11 } set a6 { 1 11 8 13 } set b6 { 8 11 14 13 } set c6 { 14 11 21 13 } set a7 { 1 13 8 15 } set b7 { 8 13 14 15 } set c7 { 14 13 21 15 } set a8 { 1 15 8 17 } set b8 { 8 15 14 17 } set c8 { 14 15 21 17 } ### Fuzzyness starts here: proc start01 {w} { puts "setup for german fuzzyclock#DE1" # 8x3 panels: "fünf Minuten vor halb vier Uhr" destroy $w; pack [canvas $w -width 200 -height 260 -background grey] set ::scX 9 if { $::pos < 0 } { wm geom . +50+20 } #makeText $w t_N "Es wird" { 1 1 4 3 } makeText $w t_N "Es wird" $::a1 makeText $w t_I "Es ist" $::b1 makeText $w t_W "Es war" $::c1 makeText $w t_v "fünf" $::a2 makeText $w t_x "zehn" $::b2 makeText $w t_M "Minuten" $::c2 makeText $w t_B "vor" $::a3 makeText $w t_P "nach" $::b3 makeText $w t_h "halb" $::c3 makeText $w t_1 "ein" $::a4 makeText $w t_2 "zwei" $::b4 makeText $w t_3 "drei" $::c4 makeText $w t_4 "vier" $::a5 makeText $w t_5 "fünf" $::b5 makeText $w t_6 "sechs" $::c5 makeText $w t_7 "sieben" $::a6 makeText $w t_8 "acht" $::b6 makeText $w t_9 "neun" $::c6 makeText $w t_10 "zehn" $::a7 makeText $w t_11 "elf" $::b7 makeText $w t_12 "zwölf" $::c7 makeText $w t_C "Uhr" $::a8 makeText $w t_AM "morgens" $::b8 makeText $w t_PM "abends" $::c8 array set ::mTab { 00 { t_I } 01 { t_W } 02 { t_W } 03 { t_N t_P t_v t_M } 04 { t_N t_P t_v t_M } 05 { t_I t_P t_v t_M } 06 { t_W t_P t_v t_M } 07 { t_W t_P t_v t_M } 08 { t_N t_P t_x t_M } 09 { t_N t_P t_x t_M } 10 { t_I t_P t_x t_M } 11 { t_W t_P t_x t_M } 12 { t_W t_P t_x t_M } 13 { t_N t_P t_v t_x t_M } 14 { t_N t_P t_v t_x t_M } 15 { t_I t_P t_v t_x t_M } 16 { t_W t_P t_v t_x t_M } 17 { t_W t_P t_v t_x t_M } 18 { t_N t_B t_x t_h t_M hH } 19 { t_N t_B t_x t_h t_M hH } 20 { t_I t_B t_x t_h t_M hH } 21 { t_W t_B t_x t_h t_M hH } 22 { t_W t_B t_x t_h t_M hH } 23 { t_N t_B t_v t_h t_M hH } 24 { t_N t_B t_v t_h t_M hH } 25 { t_I t_B t_v t_h t_M hH } 26 { t_W t_B t_v t_h t_M hH } 27 { t_W t_B t_v t_h t_M hH } 28 { t_N t_h hH } 29 { t_N t_h hH } 30 { t_I t_h hH } 31 { t_W t_h hH } 32 { t_W t_h hH } 33 { t_N t_P t_v t_h t_M hH } 34 { t_N t_P t_v t_h t_M hH } 35 { t_I t_P t_v t_h t_M hH } 36 { t_W t_P t_v t_h t_M hH } 37 { t_W t_P t_v t_h t_M hH } 38 { t_N t_P t_x t_h t_M hH } 39 { t_N t_P t_x t_h t_M hH } 40 { t_I t_P t_x t_h t_M hH } 41 { t_W t_P t_x t_h t_M hH } 42 { t_W t_P t_x t_h t_M hH } 43 { t_N t_B t_v t_x t_M hH } 44 { t_N t_B t_v t_x t_M hH } 45 { t_I t_B t_v t_x t_M hH } 46 { t_W t_B t_v t_x t_M hH } 47 { t_W t_B t_v t_x t_M hH } 48 { t_N t_B t_x t_M hH } 49 { t_N t_B t_x t_M hH } 50 { t_I t_B t_x t_M hH } 51 { t_W t_B t_x t_M hH } 52 { t_W t_B t_x t_M hH } 53 { t_N t_B t_v t_M hH } 54 { t_N t_B t_v t_M hH } 55 { t_I t_B t_v t_M hH } 56 { t_W t_B t_v t_M hH } 57 { t_W t_B t_v t_M hH } 58 { t_N hH } 59 { t_N hH } } .c configure -background DarkGreen ##puts $::mTab(05) } proc start02 {w} { puts "setup for german fuzzyclock#DE2" # 8x3 panels: "drei Uhr fünf und zwanzig Minuten" destroy $w; pack [canvas $w -width 200 -height 260 -background gray22] set ::scX 9 if { $::pos < 0 } { wm geom . +275+20 } makeText $w t_I "Es ist" $::a1 makeText $w t_AM "morgens" $::b1 makeText $w t_0 "null" $::c1 makeText $w t_1 "ein" $::a2 makeText $w t_2 "zwei" $::b2 makeText $w t_3 "drei" $::c2 makeText $w t_4 "vier" $::a3 makeText $w t_5 "fünf" $::b3 makeText $w t_6 "sechs" $::c3 makeText $w t_7 "sieben" $::a4 makeText $w t_8 "acht" $::b4 makeText $w t_9 "neun" $::c4 makeText $w t_10 "zehn" $::a5 makeText $w t_11 "elf" $::b5 makeText $w t_12 "zwölf" $::c5 makeText $w t_C "Uhr" $::a6 makeText $w t_v "fünf" $::b6 makeText $w t_x "zehn" $::c6 makeText $w t_+ "und" $::a7 makeText $w t_xx "zwanzig" $::b7 makeText $w t_30 "dreissig" $::c7 makeText $w t_40 "vierzig" $::a8 makeText $w t_50 "fünfzig" $::b8 makeText $w t_M "Minuten" $::c8 array set ::mTab { 00 { t_I } 01 { t_I } 02 { t_I } 03 { t_I t_v t_M } 04 { t_I t_v t_M } 05 { t_I t_v t_M } 06 { t_I t_v t_M } 07 { t_I t_v t_M } 08 { t_I t_x t_M } 09 { t_I t_x t_M } 10 { t_I t_x t_M } 11 { t_I t_x t_M } 12 { t_I t_x t_M } 13 { t_I t_v t_x t_M } 14 { t_I t_v t_x t_M } 15 { t_I t_v t_x t_M } 16 { t_I t_v t_x t_M } 17 { t_I t_v t_x t_M } 18 { t_I t_xx t_M } 19 { t_I t_xx t_M } 20 { t_I t_xx t_M } 21 { t_I t_xx t_M } 22 { t_I t_xx t_M } 23 { t_I t_v t_+ t_xx t_M } 24 { t_I t_v t_+ t_xx t_M } 25 { t_I t_v t_+ t_xx t_M } 26 { t_I t_v t_+ t_xx t_M } 27 { t_I t_v t_+ t_xx t_M } 28 { t_I t_+ t_30 t_M } 29 { t_I t_+ t_30 t_M } 30 { t_I t_+ t_30 t_M } 31 { t_I t_+ t_30 t_M } 32 { t_I t_+ t_30 t_M } 33 { t_I t_v t_+ t_30 t_M } 34 { t_I t_v t_+ t_30 t_M } 35 { t_I t_v t_+ t_30 t_M } 36 { t_I t_v t_+ t_30 t_M } 37 { t_I t_v t_+ t_30 t_M } 38 { t_I t_+ t_40 t_M } 39 { t_I t_+ t_40 t_M } 40 { t_I t_+ t_40 t_M } 41 { t_I t_+ t_40 t_M } 42 { t_I t_+ t_40 t_M } 43 { t_I t_v t_+ t_40 t_M } 44 { t_I t_v t_+ t_40 t_M } 45 { t_I t_v t_+ t_40 t_M } 46 { t_I t_v t_+ t_40 t_M } 47 { t_I t_v t_+ t_40 t_M } 48 { t_I t_+ t_50 t_M } 49 { t_I t_+ t_50 t_M } 50 { t_I t_+ t_50 t_M } 51 { t_I t_+ t_50 t_M } 52 { t_I t_+ t_50 t_M } 53 { t_I t_v t_+ t_50 t_M } 54 { t_I t_v t_+ t_50 t_M } 55 { t_I t_v t_+ t_50 t_M } 56 { t_I t_v t_+ t_50 t_M } 57 { t_I t_v t_+ t_50 t_M } 58 { t_I hH } 59 { t_I hH } } .c configure -background ForestGreen } proc start03 {w} { puts "setup for german fuzzyclock#DE3" # 8x3 panels: "morgens viertel nach elf" destroy $w; pack [canvas $w -width 205 -height 260 -background gray33] set ::scX 9.5 if { $::pos < 0 } { wm geom . +500+20 } makeText $w t_N "Es wird" $::a1 makeText $w t_I "Es ist" $::b1 makeText $w t_W "Es war" $::c1 makeText $w t_AM "morgens" $::a2 makeText $w t_PM "abends" $::b2 makeText $w t_v "fünf" $::c2 makeText $w t_x "zehn" $::a3 #makeText $w t_M "Minuten" $::b3 makeText $w t_q "viertel" $::b3 makeText $w t_B "vor" $::c3 makeText $w t_P "nach" $::a4 makeText $w t_h "halb" $::b4 makeText $w t_0 "null Uhr" $::c4 makeText $w t_1 "ein Uhr" $::a5 makeText $w t_2 "zwei Uhr" $::b5 makeText $w t_3 "drei Uhr" $::c5 makeText $w t_4 "vier Uhr" $::a6 makeText $w t_5 "fünf Uhr" $::b6 makeText $w t_6 "sechs Uhr" $::c6 makeText $w t_7 "sieben Uhr" $::a7 makeText $w t_8 "acht Uhr" $::b7 makeText $w t_9 "neun Uhr" $::c7 makeText $w t_10 "zehn Uhr" $::a8 makeText $w t_11 "elf Uhr" $::b8 makeText $w t_12 "zwölf Uhr" $::c8 #makeText $w t_C_ "Uhr" $::c9 array set ::mTab { 00 { t_I } 01 { t_W } 02 { t_W } 03 { t_N t_P t_v t_M } 04 { t_N t_P t_v t_M } 05 { t_I t_P t_v t_M } 06 { t_W t_P t_v t_M } 07 { t_W t_P t_v t_M } 08 { t_N t_P t_x t_M } 09 { t_N t_P t_x t_M } 10 { t_I t_P t_x t_M } 11 { t_W t_P t_x t_M } 12 { t_W t_P t_x t_M } 13 { t_N t_P t_q t_M } 14 { t_N t_P t_q t_M } 15 { t_I t_P t_q t_M } 16 { t_W t_P t_q t_M } 17 { t_W t_P t_q t_M } 18 { t_N t_B t_x t_h t_M hH } 19 { t_N t_B t_x t_h t_M hH } 20 { t_I t_B t_x t_h t_M hH } 21 { t_W t_B t_x t_h t_M hH } 22 { t_W t_B t_x t_h t_M hH } 23 { t_N t_B t_v t_h t_M hH } 24 { t_N t_B t_v t_h t_M hH } 25 { t_I t_B t_v t_h t_M hH } 26 { t_W t_B t_v t_h t_M hH } 27 { t_W t_B t_v t_h t_M hH } 28 { t_N t_h hH } 29 { t_N t_h hH } 30 { t_I t_h hH } 31 { t_W t_h hH } 32 { t_W t_h hH } 33 { t_N t_P t_v t_h t_M hH } 34 { t_N t_P t_v t_h t_M hH } 35 { t_I t_P t_v t_h t_M hH } 36 { t_W t_P t_v t_h t_M hH } 37 { t_W t_P t_v t_h t_M hH } 38 { t_N t_P t_x t_h t_M hH } 39 { t_N t_P t_x t_h t_M hH } 40 { t_I t_P t_x t_h t_M hH } 41 { t_W t_P t_x t_h t_M hH } 42 { t_W t_P t_x t_h t_M hH } 43 { t_N t_B t_q t_M hH } 44 { t_N t_B t_q t_M hH } 45 { t_I t_B t_q t_M hH } 46 { t_W t_B t_q t_M hH } 47 { t_W t_B t_q t_M hH } 48 { t_N t_B t_x t_M hH } 49 { t_N t_B t_x t_M hH } 50 { t_I t_B t_x t_M hH } 51 { t_W t_B t_x t_M hH } 52 { t_W t_B t_x t_M hH } 53 { t_N t_B t_v t_M hH } 54 { t_N t_B t_v t_M hH } 55 { t_I t_B t_v t_M hH } 56 { t_W t_B t_v t_M hH } 57 { t_W t_B t_v t_M hH } 58 { t_N hH } 59 { t_N hH } } .c configure -background PaleGreen4 } proc start04 {w} { puts "setup for german fuzzyclock#DE4" # 8x3 panels: "morgens viertel nach elf Uhr" destroy $w; pack [canvas $w -width 175 -height 260 -background gray44] set ::scX 8 if { $::pos < 0 } { wm geom . +725+20 } makeText $w t_N "Es wird" $::a1 makeText $w t_I "Es ist" $::b1 makeText $w t_W "Es war" $::c1 makeText $w t_AM "morgens" $::a2 makeText $w t_v "fünf" $::b2 makeText $w t_x "zehn" $::c2 makeText $w t_q "viertel" $::a3 makeText $w t_B "vor" $::b3 makeText $w t_P "nach" $::c3 makeText $w t_h "halb" $::a4 makeText $w t_0 "null" $::b4 makeText $w t_1 "ein" $::c4 makeText $w t_2 "zwei" $::a5 makeText $w t_3 "drei" $::b5 makeText $w t_4 "vier" $::c5 makeText $w t_5 "fünf" $::a6 makeText $w t_6 "sechs" $::b6 makeText $w t_7 "sieben" $::c6 makeText $w t_8 "acht" $::a7 makeText $w t_9 "neun" $::b7 makeText $w t_10 "zehn" $::c7 makeText $w t_11 "elf" $::a8 makeText $w t_12 "zwölf" $::b8 makeText $w t_C "Uhr" $::c8 array set ::mTab { 00 { t_I } 01 { t_W } 02 { t_W } 03 { t_N t_P t_v t_M } 04 { t_N t_P t_v t_M } 05 { t_I t_P t_v t_M } 06 { t_W t_P t_v t_M } 07 { t_W t_P t_v t_M } 08 { t_N t_P t_x t_M } 09 { t_N t_P t_x t_M } 10 { t_I t_P t_x t_M } 11 { t_W t_P t_x t_M } 12 { t_W t_P t_x t_M } 13 { t_N t_P t_q t_M } 14 { t_N t_P t_q t_M } 15 { t_I t_P t_q t_M } 16 { t_W t_P t_q t_M } 17 { t_W t_P t_q t_M } 18 { t_N t_B t_x t_h t_M hH } 19 { t_N t_B t_x t_h t_M hH } 20 { t_I t_B t_x t_h t_M hH } 21 { t_W t_B t_x t_h t_M hH } 22 { t_W t_B t_x t_h t_M hH } 23 { t_N t_B t_v t_h t_M hH } 24 { t_N t_B t_v t_h t_M hH } 25 { t_I t_B t_v t_h t_M hH } 26 { t_W t_B t_v t_h t_M hH } 27 { t_W t_B t_v t_h t_M hH } 28 { t_N t_h hH } 29 { t_N t_h hH } 30 { t_I t_h hH } 31 { t_W t_h hH } 32 { t_W t_h hH } 33 { t_N t_P t_v t_h t_M hH } 34 { t_N t_P t_v t_h t_M hH } 35 { t_I t_P t_v t_h t_M hH } 36 { t_W t_P t_v t_h t_M hH } 37 { t_W t_P t_v t_h t_M hH } 38 { t_N t_P t_x t_h t_M hH } 39 { t_N t_P t_x t_h t_M hH } 40 { t_I t_P t_x t_h t_M hH } 41 { t_W t_P t_x t_h t_M hH } 42 { t_W t_P t_x t_h t_M hH } 43 { t_N t_B t_q t_M hH } 44 { t_N t_B t_q t_M hH } 45 { t_I t_B t_q t_M hH } 46 { t_W t_B t_q t_M hH } 47 { t_W t_B t_q t_M hH } 48 { t_N t_B t_x t_M hH } 49 { t_N t_B t_x t_M hH } 50 { t_I t_B t_x t_M hH } 51 { t_W t_B t_x t_M hH } 52 { t_W t_B t_x t_M hH } 53 { t_N t_B t_v t_M hH } 54 { t_N t_B t_v t_M hH } 55 { t_I t_B t_v t_M hH } 56 { t_W t_B t_v t_M hH } 57 { t_W t_B t_v t_M hH } 58 { t_N hH } 59 { t_N hH } } .c configure -background SeaGreen4 } ### proc start08 {w} { puts "setup for german fuzzy shipclock / glasen" # 8x3 panels: "zweite Tagwache drei Glasen und fünf und zwanzig Minuten" destroy $w; pack [canvas $w -width 270 -height 260 -background gray80] set ::scX 12.5 if { $::pos < 0 } { wm geom . +450+340 } makeText $w t_gI "Es ist" $::a1 makeText $w t_Su "Sonntag" $::b1 makeText $w t_HN "Mittag" $::c1 makeText $w t_w1 "erste" $::a2 ;# 04:00 makeText $w t_w2 "zweite" $::b2 ;# 08:00 makeText $w t_w3 "dritte" $::c2 ;# 12:00 makeText $w t_w4 "vierte" $::a3 ;# 16:00 makeText $w t_dw "Tagwache" $::b3 makeText $w t_nw "Nachtwache" $::c3 ;# 20:00 / 00:00 makeText $w t_g1 "ein Glasen" $::a4 makeText $w t_g2 "zwei Glasen" $::b4 makeText $w t_g3 "drei Glasen" $::c4 makeText $w t_g4 "vier Glasen" $::a5 makeText $w t_g5 "fünf Glasen" $::b5 makeText $w t_g6 "sechs Glasen" $::c5 makeText $w t_g7 "sieben Glasen" $::a6 makeText $w t_g8 "acht Glasen" $::b6 #makeText $w t_G "Glasen" $::c6 makeText $w t_+1 "und" $::a7 makeText $w t_gv "fünf" $::b7 makeText $w t_gx "zehn" $::c7 makeText $w t_+2 "und" $::a8 makeText $w t_gz "zwanzig" $::b8 makeText $w t_gM "Minuten" $::c8 ## see also: proc upd array set ::sTab { w1 { t_w1 t_dw } w2 { t_w2 t_dw } w3 { t_w3 t_dw } w4 { t_w4 t_dw } w5 { t_w1 t_nw } w0 { t_w2 t_nw } 5 { t_+1 t_gv t_gM } 10 { t_+1 t_gx t_gM } 15 { t_+1 t_gv t_gx t_gM } 20 { t_+1 t_gz t_gM } 25 { t_+1 t_gv t_+2 t_gz t_gM } } .c configure -background MediumBlue ;# blue4 } proc start09 {w} { puts "setup for international fuzzy ship's bell" # 8x3 panels: "Forenoon watch three bells and twenty five minutes" destroy $w; pack [canvas $w -width 260 -height 260 -background gray90] set ::scX 12 if { $::pos < 0 } { wm geom . +740+360 } makeText $w t_gI "It is" $::a1 makeText $w t_Su "Sunday" $::b1 makeText $w t_w5 "First" $::c1 ;# 20:00 makeText $w t_w0 "Middle" $::a2 ;# 00:00 makeText $w t_w1 "Morning" $::b2 ;# 04:00 makeText $w t_w2 "Forenoon" $::c2 ;# 08:00 makeText $w t_w3 "Afternoon" $::a3 ;# 12:00 makeText $w t_w4 "Dog" $::b3 ;# 16:00 makeText $w t_gW "watch" $::c3 makeText $w t_g1 "one bell" $::a4 makeText $w t_g2 "two bells" $::b4 makeText $w t_g3 "three bells" $::c4 makeText $w t_g4 "four bells" $::a5 makeText $w t_g5 "five bells" $::b5 makeText $w t_g6 "six bells" $::c5 makeText $w t_g7 "seven bells" $::a6 makeText $w t_g8 "eight bells" $::b6 #makeText $w t_G "bells" $::c6 makeText $w t_HN "Noon" $::c6 makeText $w t_+1 "and" $::a7 makeText $w t_gx "ten" $::b7 makeText $w t_gF "fifteen" $::c7 makeText $w t_gz "twenty" $::a8 makeText $w t_gv "five" $::b8 makeText $w t_gM "minutes" $::c8 array set ::sTab { w0 { t_w0 t_gW } w1 { t_w1 t_gW } w2 { t_w2 t_gW } w3 { t_w3 t_gW } w4 { t_w4 t_gW } w5 { t_w5 t_gW } 5 { t_+1 t_gv t_gM } 10 { t_+1 t_gx t_gM } 15 { t_+1 t_gF t_gM } 20 { t_+1 t_gz t_gM } 25 { t_+1 t_gv t_gz t_gM } } .c configure -background MidnightBlue ;# Navy NavyBlue } ### proc start11 {w} { puts "setup for international fuzzyclock#1" # 8x3 panels: "three o'clock twenty five minutes" destroy $w; pack [canvas $w -width 175 -height 260 -background gray11] set ::scX 8 if { $::pos < 0 } { wm geom . +50+320 } makeText $w t_I "It is" $::a1 makeText $w t_AM "AM" $::b1 makeText $w t_0 "zero" $::c1 makeText $w t_1 "one" $::a2 makeText $w t_2 "two" $::b2 makeText $w t_3 "three" $::c2 makeText $w t_4 "four" $::a3 makeText $w t_5 "five" $::b3 makeText $w t_6 "six" $::c3 makeText $w t_7 "seven" $::a4 makeText $w t_8 "eight" $::b4 makeText $w t_9 "nine" $::c4 makeText $w t_10 "ten" $::a5 makeText $w t_11 "eleven" $::b5 makeText $w t_12 "twelve" $::c5 makeText $w t_C "o'clock" $::a6 makeText $w t_x "ten" $::b6 makeText $w t_xv "fifteen" $::c6 makeText $w t_xx "twenty" $::a7 makeText $w t_30 "thirty" $::b7 makeText $w t_40 "fourty" $::c7 makeText $w t_50 "fifty" $::a8 makeText $w t_v "five" $::b8 makeText $w t_M "minutes" $::c8 array set ::mTab { 00 { t_I } 01 { t_I } 02 { t_I } 03 { t_I t_v t_M } 04 { t_I t_v t_M } 05 { t_I t_v t_M } 06 { t_I t_v t_M } 07 { t_I t_v t_M } 08 { t_I t_x t_M } 09 { t_I t_x t_M } 10 { t_I t_x t_M } 11 { t_I t_x t_M } 12 { t_I t_x t_M } 13 { t_I t_xv t_M } 14 { t_I t_xv t_M } 15 { t_I t_xv t_M } 16 { t_I t_xv t_M } 17 { t_I t_xv t_M } 18 { t_I t_xx t_M } 19 { t_I t_xx t_M } 20 { t_I t_xx t_M } 21 { t_I t_xx t_M } 22 { t_I t_xx t_M } 23 { t_I t_v t_+ t_xx t_M } 24 { t_I t_v t_+ t_xx t_M } 25 { t_I t_v t_+ t_xx t_M } 26 { t_I t_v t_+ t_xx t_M } 27 { t_I t_v t_+ t_xx t_M } 28 { t_I t_30 t_M } 29 { t_I t_30 t_M } 30 { t_I t_30 t_M } 31 { t_I t_30 t_M } 32 { t_I t_30 t_M } 33 { t_I t_v t_+ t_30 t_M } 34 { t_I t_v t_+ t_30 t_M } 35 { t_I t_v t_+ t_30 t_M } 36 { t_I t_v t_+ t_30 t_M } 37 { t_I t_v t_+ t_30 t_M } 38 { t_I t_40 t_M } 39 { t_I t_40 t_M } 40 { t_I t_40 t_M } 41 { t_I t_40 t_M } 42 { t_I t_40 t_M } 43 { t_I t_v t_+ t_40 t_M } 44 { t_I t_v t_+ t_40 t_M } 45 { t_I t_v t_+ t_40 t_M } 46 { t_I t_v t_+ t_40 t_M } 47 { t_I t_v t_+ t_40 t_M } 48 { t_I t_50 t_M } 49 { t_I t_50 t_M } 50 { t_I t_50 t_M } 51 { t_I t_50 t_M } 52 { t_I t_50 t_M } 53 { t_I t_v t_50 t_M } 54 { t_I t_v t_50 t_M } 55 { t_I t_v t_50 t_M } 56 { t_I t_v t_50 t_M } 57 { t_I t_v t_50 t_M } 58 { t_I hH } 59 { t_I hH } } .c configure -background FireBrick ;# maroon } proc start12 {w} { puts "setup for international fuzzyclock#2" # 8x3 panels: "quarter past three o'clock" destroy $w; pack [canvas $w -width 175 -height 260 -background grey12] set ::scX 8 if { $::pos < 0 } { wm geom . +250+320 } makeText $w t_I "It is" $::a1 makeText $w t_AM "AM" $::b1 makeText $w t_x "ten" $::c1 makeText $w t_q "a quarter" $::a2 makeText $w t_xx "twenty" $::b2 makeText $w t_h "half" $::c2 makeText $w t_v "five" $::a3 makeText $w t_M "minutes" $::b3 makeText $w t_B "before" $::c3 makeText $w t_P "past" $::a4 makeText $w t_0 "zero" $::b4 makeText $w t_1 "one" $::c4 makeText $w t_2 "two" $::a5 makeText $w t_3 "three" $::b5 makeText $w t_4 "four" $::c5 makeText $w t_5 "five" $::a6 makeText $w t_6 "six" $::b6 makeText $w t_7 "seven" $::c6 makeText $w t_8 "eight" $::a7 makeText $w t_9 "nine" $::b7 makeText $w t_10 "ten" $::c7 makeText $w t_11 "eleven" $::a8 makeText $w t_12 "twelve" $::b8 makeText $w t_C "o'clock" $::c8 array set ::mTab { 00 { t_I } 01 { t_I } 02 { t_I } 03 { t_I t_P t_v t_M } 04 { t_I t_P t_v t_M } 05 { t_I t_P t_v t_M } 06 { t_I t_P t_v t_M } 07 { t_I t_P t_v t_M } 08 { t_I t_P t_x t_M } 09 { t_I t_P t_x t_M } 10 { t_I t_P t_x t_M } 11 { t_I t_P t_x t_M } 12 { t_I t_P t_x t_M } 13 { t_I t_P t_q t_ } 14 { t_I t_P t_q t_ } 15 { t_I t_P t_q t_ } 16 { t_I t_P t_q t_ } 17 { t_I t_P t_q t_ } 18 { t_I t_P t_xx t_M } 19 { t_I t_P t_xx t_M } 20 { t_I t_P t_xx t_M } 21 { t_I t_P t_xx t_M } 22 { t_I t_P t_xx t_M } 23 { t_I t_P t_v t_xx t_M } 24 { t_I t_P t_v t_xx t_M } 25 { t_I t_P t_v t_xx t_M } 26 { t_I t_P t_v t_xx t_M } 27 { t_I t_P t_v t_xx t_M } 28 { t_I t_h t_P } 29 { t_I t_h t_P } 30 { t_I t_h t_P } 31 { t_I t_h t_P } 32 { t_I t_h t_P } 33 { t_I t_B t_v t_xx t_M hH } 34 { t_I t_B t_v t_xx t_M hH } 35 { t_I t_B t_v t_xx t_M hH } 36 { t_I t_B t_v t_xx t_M hH } 37 { t_I t_B t_v t_xx t_M hH } 38 { t_I t_B t_xx t_M hH } 39 { t_I t_B t_xx t_M hH } 40 { t_I t_B t_xx t_M hH } 41 { t_I t_B t_xx t_M hH } 42 { t_I t_B t_xx t_M hH } 43 { t_I t_B t_q t_ hH } 44 { t_I t_B t_q t_ hH } 45 { t_I t_B t_q t_ hH } 46 { t_I t_B t_q t_ hH } 47 { t_I t_B t_q t_ hH } 48 { t_I t_B t_x t_M hH } 49 { t_I t_B t_x t_M hH } 50 { t_I t_B t_x t_M hH } 51 { t_I t_B t_x t_M hH } 52 { t_I t_B t_x t_M hH } 53 { t_I t_B t_v t_M hH } 54 { t_I t_B t_v t_M hH } 55 { t_I t_B t_v t_M hH } 56 { t_I t_B t_v t_M hH } 57 { t_I t_B t_v t_M hH } 58 { t_I hH } 59 { t_I hH } } .c configure -background Red4 ;# OrangeRed4 } ### Main: wm title . "$Prog(title) $Prog(version)" puts "$Prog(title) $Prog(version)" bind . <F2> { console show } #catch {console show} ;## #catch {console hide} ;## # Defaults: set fc "i2" ;# Layout: G:Glasen"=german shipclock / SB:ship's bell international set pos -1 ;# screen: -1:distribute the layouts on screen set sound 0 ;# sound: 0:none 1:once on full hour 2: ship's bell set cons 0 ;# console: debug if { $argc > 0 } { set i 0 foreach arg $::argv { incr i puts "argument $i is $arg" ;## set hyp [string first "-" $arg] if { $hyp >= 0 } { if { $arg == "-p0" } { ;# don't set screen-position set pos 0 } elseif { $arg == "-p1" } { ;# top left set pos 1 } elseif { $arg == "-p2" } { ;# top right set pos 2 } elseif { $arg == "-s0" } { ;# no sound set sound 0 } elseif { $arg == "-s1" } { ;# once set sound 1 } elseif { $arg == "-s2" } { ;# ship's bell / Glasen set sound 2 } elseif { $arg == "-cS" } { catch {console show} ;## } elseif { $arg == "-cH" } { catch {console hide} ;## } } else { set fc $arg } } } puts "Args: fc,pos,sound: $fc $pos $sound" ;## if { $fc == "1" || $fc == "DE1" || $fc == "DE" } { start01 .c ;#DE1 : german fuzzyclock: "fünf Minuten vor halb vier Uhr" } elseif { $fc == "2" || $fc == "DE2"} { start02 .c ;#DE2 : german fuzzyclock: "drei Uhr fünf und zwanzig Minuten" } elseif { $fc == "3" || $fc == "DE3"} { start03 .c ;#DE3 : german fuzzyclock: "viertel nach drei" } elseif { $fc == "4" || $fc == "DE4"} { start04 .c ;#DE4 : german fuzzyclock: "viertel nach drei Uhr" } elseif { $fc == "8" || $fc == "G"} { set fc "G" start08 .c ;#8 : german shipclock: 09:55 --> "zweite Tagwache drei Glasen und fünf und zwanzig Minuten" } elseif { $fc == "9" || $fc == "SB"} { set fc "SB" start09 .c ;#9 : international ship's bell: "Forenoon watch three bells and twenty five minutes" } elseif { $fc == "11" || $fc == "I1" || $fc == "i1"} { start11 .c ;#11: international fuzzyclock: "three o'clock twenty five minutes" } elseif { $fc == "12" || $fc == "I2" || $fc == "i2"} { start12 .c ;#12: international fuzzyclock: "quarter past three o'clock" } else { puts "Selection invalid: '$fc', using default layout." set fc "I2" start12 .c ;#12: international fuzzyclock: "quarter past three o'clock" } if { $::pos == 1 } { p1 } if { $::pos == 2 } { p2 } focus -f .c update help now after 250 u #sync0 #run0 run ### EOF ###
(picture goes here)
if 0 {
MiHa 2015-02-24 - Some bugfixes for the minute-table, and improved wiki-formatting.
MiHa 2015-03-03 - I added two more versions for a german fuzzyclock "morgens viertel nach elf Uhr", meaning "quarter past eleven".
Rearranging the panels is much more easy to do now with the spreadsheet-addressing, then with the old list of coordinates.
To avoid adding another row of panels, the entries for "PM"/"evening" and "minutes" had to be dropped.
Some ideas for further programming:
To sum up the experience:
kpv Also check out Word Clock for another textual clock.
MiHa Yes - it has already been on the list, right before "Designers notes".
MiHa 2015-03-04 - Now finally with an international fuzzyclock "quarter before/past".
MiHa 2015-03-05 - I changed the coordinates and scale, to get finer grained text-positioning,
as well as adjustable columnwidth for each of the layouts.
Further, I gave each layout its very own position on the screen.
When starting, the program now looks at argv, and processes the commandline-arguments.
That works both with tclsh and wish.
Currently implemented commandline-arguments to control layout, sound, and placement on the screen:
With all that plumbing in place, it is now easy to show all the layouts at once, and compare them.
(Re-using my test-setup as a showcase:)
To see this in action, use a batchfile (for Windows) such as the following
to start one tcl-interpreter for each of the layouts:
start wish FuzzyClock.tcl DE1 start wish FuzzyClock.tcl DE2 start wish FuzzyClock.tcl DE3 start wish FuzzyClock.tcl DE4 start wish FuzzyClock.tcl I1 start wish FuzzyClock.tcl I2 start wish FuzzyClock.tcl G start wish FuzzyClock.tcl SB -s2
That means, all these clocks are running with no sound, except for the one with -s2,
and all the layouts get distributed to different places across the screen.
MiHa 2015-03-13 - I have created layouts for ship's bell / "Glasenuhr"
http://en.wikipedia.org/wiki/Ship%27s_bell / http://de.wikipedia.org/wiki/Glasenuhr
with both a german and an international version.
My international ship's bell uses the "simpler system" according to the wikipedia-page,
that is, without the dogwatch split into two parts.
Not being a sailor, that looks like the Standard merchant watch system to me.
To summarise the concept for the ship's clock:
To bring those shipclocks to the same "fuzzy precision" as the other clocks, I added 5-minute "lights".
But they wait for the exact time, and don't round up.
That means, at 19:23 the fuzzy clocks would say "twenty five minutes",
but the shipclocks would then still say "twenty minutes", and wait until reaching 19:25 to show "twenty five minutes".
Finally, I changed the "every" and "sync"-mechanism to use a more gentle approach
to bring the screen-updates to occur on multiples of 10 seconds.
The old coding made the program unresponsive during the first few seconds.
If you find a bug, or have an idea for some original layout, let me know !
Otherwise, have fun !
}