#!/usr/bin/env perl
require
5.002;
sub
tick;
my
$MW
= MainWindow->new;
$MW
->
bind
(
'<Control-c>'
=> \
&exit
);
$MW
->
bind
(
'<Control-q>'
=> \
&exit
);
my
(
%tinfo
) = (
'w'
=>
$MW
,
's'
=> 0,
'h'
=> 0,
'p'
=> 1,
't'
=>
'0.00'
);
my
$start
=
$MW
->Button(
-text
=>
'Start'
,
-command
=>
sub
{
if
(
$tinfo
{
'p'
}) {
$tinfo
{
'p'
} = 0; tick}},
);
my
$stop
=
$MW
->Button(
-text
=>
'Stop'
,
-command
=>
sub
{
$tinfo
{
'p'
} = 1;});
my
$counter
=
$MW
->Label(
-relief
=>
'raised'
,
-width
=> 10,
-textvariable
=> \
$tinfo
{
't'
},
);
$counter
->
pack
(
-side
=>
'bottom'
,
-fill
=>
'both'
);
$start
->
pack
(
-side
=>
'left'
,
-fill
=>
'both'
,
-expand
=>
'yes'
);
$stop
->
pack
(
-side
=>
'right'
,
-fill
=>
'both'
,
-expand
=>
'yes'
);
sub
tick {
return
if
$tinfo
{
'p'
};
$tinfo
{
'h'
} += 5;
if
(
$tinfo
{
'h'
} >= 100) {
$tinfo
{
'h'
} = 0;
$tinfo
{
's'
}++;
}
$tinfo
{
't'
} =
sprintf
(
"%d.%02d"
,
$tinfo
{
's'
},
$tinfo
{
'h'
});
$tinfo
{
'w'
}->
after
(50, \
&tick
);
}
MainLoop;