aboutsummaryrefslogtreecommitdiff
path: root/challenge-028/e-choroba/perl5/ch-2.pl
blob: 7376c02a578fde00138701c2f79af877ed87488e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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();