NAME
Tk::Clock - Clock widget with analog and digital display
SYNOPSIS
use Tk use Tk::Clock;
$clock = $parent->Clock (?-option => <value> ...?);
$clock->config ( # These reflect the defaults useDigital => 1, useAnalog => 1, anaScale => 100, handColor => "Green4", secsColor => "Green2", tickColor => "Yellow4", tickFreq => 1, timeFont => "fixed", timeColor => "Red4", timeFormat => "HH.MM:SS", dateFont => "fixed", dateColor => "Blue4", dateFormat => "dd-mm-yy");
DESCRIPTION
Create a clock canvas with both an analog- and a digital display. Either can be disabled by setting useAnalog or useDigital to 0 resp.
Legal dateFormat characters are d and dd for date, ddd and dddd for weekday, m, mm, mmm and mmmm for month, y and yy for year, w and ww for weeknumber and any separators :, -, / or space.
Legal timeFormat characters are H and HH for hour, h and hh for AM/PM hour, M and MM for minutes, S and SS for seconds, A for AM/PM indicator, d and dd for day-of-the week in two or three characters resp. and any separators :, -, . or space.
Meaningful values for tickFreq are 1, 5 and 15 showing all ticks, tick every 5 minutes or the four main ticks only, though any positive integer will do (put a tick on any tickFreq minute).
The analog clock can be enlaged or reduced using anaScale for which the default of 100% is about 72x72 pixels. Future enhancement will include auto sizing for anaScale 0.
When using pack
for your geometry management, be sure to pass -expand => 1, -fill => "both"
if you plan to resize with anaScale
or enable/disable either analog or digital after the clock was displayed.
BUGS
If the system load's too high, the clock might skip some seconds.
Due to the fact that the year is expressed in 2 digit's, this widget is not Y2K compliant in the default configuration.
There's no check if either format will fit in the given space.
TODO
* Using POSIX' strftime () for dateFormat. Current implementation would probably make this very slow. * Auto sizing to fit (analog) clock in given space. that is the reverse of what happens now.
AUTHOR
H.Merijn Brand <h.m.brand@xs4all.nl>
Thanks to Larry Wall for inventing perl. Thanks to Nick Ing-Simmons for providing perlTk. Thanks to Achim Bohnet for introducing me to OO (and converting the basics of my clock.pl to Tk::Clock.pm). Thanks to Sriram Srinivasan for understanding OO though his Panther book. Thanks to all CPAN providers for support of different modules to learn from. Thanks to all who have given me feedback.
COPYRIGHT AND LICENSE
Copyright (C) 1999-2005 H.Merijn Brand
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.