tcf03 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Net::Ping; use Tk; use Tk::Dialog; my $mw; my $shift; my $port; my @Addr=( 1 ... 55 ); my $statbar; $mw = MainWindow->new; $mw->title("AP ping"); $mw->geometry("203x595"); $mw->Label(-text => 'Choose Access Point to Ping')->place(-x => 5, -y +=> 5); $statBar = $mw->Label(-text => '', -font => [-family => 'Lucida Console +', -size => 8], -width => 28, -relief => 'groove')->place(-x => 0, - +y => 575); $mw->Button(-text => "Get Status", -relief => 'groove', -command => sub { $statBar->configure(-text => "pinging $h +ost"); if ( $host eq "All" ) { \&mstat($_) for +( 1 .. scalar(@Addr)) } else { \&mstat($host); } })->place(-x => + 60, -y => 70); $mw->Button(-text => "Exit", -relief => 'groove', -command => sub { exit })->place(-x => 172, -y => 70); my $tagOM = $mw->Optionmenu(-variable => \$host, -options => [ '', 'All', @Addr ], -width => 25, -relief => 'groove', -command => sub {})->place(-x => 5, -y => 30 +); my $statLog = $mw->Scrolled("Text", -scrollbars => 'e', -height => 30, + width=> 25)->place(-x => 0, -y => 130); MainLoop; ############# sub mstat ############# { $ap = shift; my $host = sprintf ("192.9.210.1%02d", $ap); my $p = Net::Ping->new(); if ( $p->ping($host)) { $statLog->insert('end', "AP $host is up\n"); #$statBar->configure(-text => "pinging $host is up"); } else { $statLog->insert('end', "AP $host is down\n"); #$statBar->configure(-text => "AP $host is down") } $p->close(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl/Tk and realtime update of output
by gri6507 (Deacon) on Nov 09, 2005 at 16:57 UTC | |
|
Re: perl/Tk and realtime update of output
by bageler (Hermit) on Nov 09, 2005 at 18:06 UTC |