From 1094f66e2e32869b2c9dc937a7a7d2b5f55e1120 Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Tue, 1 Oct 2019 20:18:15 +0200 Subject: Add solution to 028/2 (Digital clock) by E. Choroba --- challenge-028/e-choroba/perl5/ch-2.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 challenge-028/e-choroba/perl5/ch-2.pl 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(); -- cgit