Tagged: "Yad Clock"
- This topic has 4 replies, 1 voice, and was last updated Jun 17-8:02 pm by Brian Masinick.
-
AuthorPosts
-
June 15, 2022 at 8:41 pm #84641Moderator
Brian Masinick
Here is another script; this one is written in TCL, includes the latest Tk library, which uses the “wish” extensions.
I did not write this script; I believe in reusing code where possible, citing the original source.
Without further delay, here is a script I found that provides dual clocks:#! /bin/env tclsh # Copied from https://wiki.tcl-lang.org/page/Tk+Dual+Zone+Clock # by Brian Masinick on June 15, 2022 # This is a dual clock, where you can look at two clocks in different time zones, # display two visual clocks, or shrink the display to only show a single clock. package require Tk 8.6 namespace eval dualclock { namespace export create namespace ensemble create proc create {{w {}}} { variable state variable timezones if {$w == {.}} { set parent {} } namespace eval [set id [info cmdcount]] {} foreach varname {local_tz other_tz local_time other_date updaterunning} { variable ${id}::$varname } set updaterunning 0 set ${id}::w $w set now [clock scan now] #synchronize with the system clock so that the [after] fires task approximately on the second while {[clock scan now] eq $now} {} after idle--
Brian MasinickJune 15, 2022 at 9:11 pm #84643Moderator
Brian Masinick
::I decided to make another modified version of clock.tcl, so I took the original code, took out the “other” instance, leaving the “local” instance, and I got the changes right on my first attempt, so I actually was able to understand the code, (at least to some extent) enough to create this version, also citing https://wiki.tcl-lang.org/page/Tk+Dual+Zone+Clock as my source.
#! /bin/env tclsh # Copied from https://wiki.tcl-lang.org/page/Tk+Dual+Zone+Clock # by Brian Masinick on June 15, 2022 # This was a dual clock, where you can look at two clocks in different time zones. # I modified the original script to display a single clock, which can be easily # set to different timezones around the world. package require Tk 8.6 namespace eval myclock { namespace export create namespace ensemble create proc create {{w {}}} { variable state variable timezones if {$w == {.}} { set parent {} } namespace eval [set id [info cmdcount]] {} foreach varname {local_tz local_time updaterunning} { variable ${id}::$varname } set updaterunning 0 set ${id}::w $w set now [clock scan now] #synchronize with the system clock so that the [after] fires task approximately on the second while {[clock scan now] eq $now} {} after idle--
Brian MasinickJune 17, 2022 at 6:04 pm #84737Moderator
Brian Masinick
::The one thing this script does not EXPLICITLY specify is the color scheme; that is picked up (by default) from the combination of .Xdefault, .Xresources and any other resource files that DO specify color. You CAN override color explicitly by setting it in the program or the command line arguments, either of which will override configuration resource files.
I’ll explore this further too, but I may not get to it today.
How I discovered this (and remembered the order of presidence) is that I ran it on two different systems with different color scheme settings and got a much different visual appearance from the same exact script.
--
Brian MasinickJune 17, 2022 at 7:59 pm #84746Moderator
Brian Masinick
::On both of the scripts above, please note the lines that have the ::update_time $id]]
These should all be included in the line that has
after 1000::update_time $id]]
or similar statements.--
Brian MasinickJune 17, 2022 at 8:02 pm #84747Moderator
Brian Masinick
::Even my updated note formats the string; apparently the two “:” cause formatting here, even with code quotation in place.
If you try out the scripts, make sure to put those lines together with their preceding lines.
To get the original code, visit https://wiki.tcl-lang.org/page/Tk+Dual+Zone+Clock--
Brian Masinick -
AuthorPosts
- You must be logged in to reply to this topic.