transiency has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Tk; use strict; use warnings; use subs qw/samp destruct restartsamp/; my $mw = MainWindow->new; $mw->minsize(400,300); $mw->maxsize(1024,768); my $srate; my $dosample = 1; my $smpratelbl = $mw->Label(-text=> "Enter Sample Rate [msec]"); my $smprate = $mw->Entry(-textvariable=>\$srate); my $startsmp = $mw->Button(-text => "Sample/Change Rate", -command => sub{my $smp = $mw->repeat( +$srate, \&samp)}); my $stopsmp = $mw->Button(-text => "Stop Sampling", -command => \&destruct); my $restartsmp = $mw->Button(-text => "Restart Sampling", -command => \&restartsamp); $smpratelbl->pack; $smprate->pack; $startsmp->pack; $restartsmp->pack; $stopsmp->pack; MainLoop; sub destruct(){ $dosample = 0; } sub restartsamp(){ $dosample = 1; } sub samp(){ my $temp1; if($dosample == 1){ my $temp1 = localtime; print "$temp1 $srate\n"; my $temp2 = "$temp1 " . "$srate\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::Repeat - Variable Rate?
by ~~David~~ (Hermit) on Mar 30, 2009 at 22:32 UTC | |
by transiency (Sexton) on Mar 30, 2009 at 22:38 UTC |