I've written a small Tcl/Tk script for a friend that displays the current time, as well as a quote. He uses it in some project with a Raspberry Pi, and since I didn't want to cobble up something up in Qt, PyQt, or some kind of website, I tried to write something in Tcl/Tk.
Demo
Here is how it looks in the end:
Requirements
This script assumes that you have fortune
available an in your $PATH
.
Script
#!/usr/bin/env tclsh
proc every {ms body} {
eval $body
after $ms [info level 0]
}
label .time -bg black -fg white -font {Arial 150} -textvar ::time -pady 30
every 1000 { set ::time [clock format [clock sec] -format "%T"] }
label .fortune -bg black -fg white -font {Arial 15} -textvar ::fortune
every 30000 { set ::fortune [exec fortune -s] }
pack .time -fill both
pack .fortune -fill both -expand 1
. configure -bg black
wm attributes . -fullscreen 1
bind . <q> exit
What to review
This is my first script in Tcl/Tk. Feel free to commend on anything, especially if there's some kind of common style I'm missing.