JSlice has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to set the background color of an individual entry in a perl tk listbox. So for instance, i may have a list of batch compute jobs that are running that is updated every 10 seconds, and any with errors reported would change to a red background in the list.
Is this possible? I know i can do it with a textbox, but a listbox?
thanks!
JSlice
Sure, just set the (appropriately named) -background option to whatever you want.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $top = MainWindow->new;
my @color = qw/red yellow pink green purple orange blue/;
my $listbox = $top->Scrolled('Listbox')->pack;
for (0..99){
$listbox->insert('end',$_);
$listbox->itemconfigure($_, -background => $color[rand(@color)]);
}
MainLoop;