aboutsummaryrefslogtreecommitdiff
path: root/challenge-028
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2019-10-01 20:18:15 +0200
committerE. Choroba <choroba@matfyz.cz>2019-10-01 20:18:15 +0200
commit1094f66e2e32869b2c9dc937a7a7d2b5f55e1120 (patch)
tree84279b56dcc1954f27c41b06adbf7303f19cd688 /challenge-028
parent480895c26cca1910eab796c148fed2cdd37e0f0e (diff)
downloadperlweeklychallenge-club-1094f66e2e32869b2c9dc937a7a7d2b5f55e1120.tar.gz
perlweeklychallenge-club-1094f66e2e32869b2c9dc937a7a7d2b5f55e1120.tar.bz2
perlweeklychallenge-club-1094f66e2e32869b2c9dc937a7a7d2b5f55e1120.zip
Add solution to 028/2 (Digital clock) by E. Choroba
Diffstat (limited to 'challenge-028')
-rwxr-xr-xchallenge-028/e-choroba/perl5/ch-2.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-028/e-choroba/perl5/ch-2.pl b/challenge-028/e-choroba/perl5/ch-2.pl
new file mode 100755
index 0000000000..7376c02a57
--- /dev/null
+++ b/challenge-028/e-choroba/perl5/ch-2.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Time::Piece;
+use Tk;
+
+my $time;
+sub init_time { $time = localtime->strftime('%H:%M:%S') }
+
+my $rate = 500;
+
+my $mw = 'MainWindow'->new(-title => 'Digital Clock');
+
+$mw->Label(-textvariable => \$time,
+ -font => 'Arial 48',
+)->pack;
+
+my $repeat_id = $mw->repeat($rate, \&init_time);
+
+my $scale = $mw->Scale(-label => 'Refresh rate:',
+ -orient => 'horizontal',
+ -from => 1,
+ -to => 2000,
+ -command => sub { $repeat_id->time($rate = $_[0]) },
+)->pack;
+$scale->set($rate);
+
+init_time();
+MainLoop();