aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();