4 Einträge, 1 Seite |
$top = new MainWindow();#-use => $Plugin::brinfo{xwindow_id});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw/time/;
use Tk;
my ($Startzeit, $Zeit, $Delta, $Ticker)=(0,0,0,undef);
my $Mw = MainWindow->new;
$Mw->Label(-textvariable => \$Zeit)->pack;
my $Fr = $Mw->Frame->pack;
$Fr->Button(-text => 'Start', -command => \&start)->pack(-side => 'left');
$Fr->Button(-text => 'Stop', -command => \&stop)->pack(-side => 'left');
$Fr->Button(-text => 'Reset', -command => \&reset)->pack(-side => 'left');
show(0);
$Mw->MainLoop;
sub start { return if $Ticker; $Startzeit = time - $Delta; $Ticker = $Mw->repeat(50, \&calc) }
sub stop { $Mw->afterCancel($Ticker) if $Ticker; $Ticker = undef }
sub reset { $Delta = 0; show(0) }
sub calc { $Delta = time - $Startzeit; show($Delta) }
sub show { $Zeit = sprintf "%d:%02d.%02d", int($_[0]/60), $_[0]%60, int(($_[0] - int $_[0])*100) }
4 Einträge, 1 Seite |