in reply to TK refresh widgit data
#!/usr/bin/perl use strict; use warnings; use Tk; my @array = ('red','green','yellow'); my @host_array = qw(server1 server2 server3 server4); my %labs; my $window = MainWindow->new(); $window->minsize( qw(250 250)); $window->title("Server Status"); $window->configure (-background => 'grey'); my $top = $window->Frame(-background => 'grey',)->pack(-side=>'top',-f +ill=>'x'); foreach my $host (@host_array){ $labs{$host} = $top->Label(-text=>"$host",-background => 'white')-> +pack(); } #$window->Button(-text => "Refresh", -command => \&pinghost )->pack; my $timer = $window->repeat(2000,\&pinghost); $window->Button(-text => "Quit", -command => \&Quit )->pack; #&pinghost; MainLoop(); ######################################################### sub pinghost{ foreach my $host (@host_array) { push (@array,shift(@array)); my $color = $array[0]; my $rand = rand 1; $labs{$host}->configure(-text=>"$host-$rand", -background => "$col +or"); } #$window->update; } sub Quit{ exit; }
|
|---|