Added custom field type support to Form
[tcl-tlc.git] / scripts / clock.itk
blob22572e9c4c1cf32f7f2ff1b6b047ad03ece5768c
1 # vim: foldmarker=<<<,>>>
3 class tlc::Clock {
4         inherit tlc::Mywidget
6         constructor {args} {}
7         destructor {}
9         public {
10                 variable update_interval        50
11         }
13         private {
14                 variable afterid        ""
15                 variable time           ""
16                 variable day            ""
17                 variable date           ""
18                 variable last           0
20                 method update_disp {}
21         }
25 body tlc::Clock::constructor {args} { #<<<1
26         eval itk_initialize $args
28         label $w.time -textvariable [scope time]
29         label $w.day -textvariable [scope day]
30         label $w.date -textvariable [scope date]
32         table $w \
33                         $w.time         1,1 -width 55 \
34                         $w.day          1,2 -width 65 \
35                         $w.date         1,3 -width 70
36         table configure $w r1 c1 c2 c3 -resize none
37         
38         update_disp
42 body tlc::Clock::destructor {} { #<<<1
43         after cancel $afterid; set afterid      ""
47 body tlc::Clock::update_disp {} { #<<<1
48         after cancel $afterid; set afterid      ""
49         set afterid     [after $update_interval [code $this update_disp]]
50         set now         [clock seconds]
51         if {$now == $last} return
52         set last        $now
53         foreach {time day date} [clock format $now -format "%H:%M:%S %A %d/%m/%Y"] break