in reply to Tk process monitoring

There are alot of ways to do this, and I'll bet if you search groups.google.com, you will find solutions.

As far as green and red indicators go, you can use just about any widget you want, and $widget->configure(-bg =>'green') and (red) at the appropraite times. The label is probably the smallest widget (as far as code size goes), but the CheckButton would be easy too, as it would let you label it too.

You will need to use a Tk::after or Tk::repeat to run your ps-test after a delay. But you can run it thru system, or check out Tk::ExecuteCommand.

#!/usr/bin/perl use Tk; use strict; use Tk::ExecuteCommand; my $mw = MainWindow->new; my $ec = $mw->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'ls -la'); $ec->execute_command; $ec->bell; $ec->update; MainLoop;
As far as changing changing colors go, here is the general idea.
#!/usr/bin/perl use Tk; use strict; use constant BUTTON_WIDTH => 20; my $mw = new MainWindow(title => "demo"); my $button = $mw->Button(text => "color", width => BUTTON_WIDTH) ->pack; $mw->Button(text => "red", width => BUTTON_WIDTH, command => sub {change_color($button, "red")}) ->pack; $mw->Button(text => "green", width => BUTTON_WIDTH, command => sub {change_color($button, "green")}) ->pack; MainLoop; sub change_color { my ($widget, $color) = @_; $widget->configure(background => $color); }

And here is a neat little method for making an indicator.

#!/usr/bin/perl use Tk; use strict; my $mw = MainWindow->new; my @color = qw/red lightgray/; my $bits = pack("b8"x8, "...11...", "..1111..", ".111111.", "11111111", "11111111", ".111111.", "..1111..", "...11...",); $mw->DefineBitmap('indicator' => 8,8, $bits); my $label = $mw->Label(-bitmap=>'indicator', -fg=>'red')->pack; $mw->repeat(500,sub{$label->configure( -fg=>$color[0]); @color=reverse(@color); }); MainLoop;

I'm not really a human, but I play one on earth. flash japh

edited: Sun Apr 4 04:39:00 2004 by jeffa - added readmore