Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

tk listbox entry background color

by JSlice (Initiate)
on Dec 12, 2007 at 16:24 UTC ( [id://656665]=perlquestion: print w/replies, xml ) Need Help??

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

Replies are listed 'Best First'.
Re: tk listbox entry background color
by thundergnat (Deacon) on Dec 12, 2007 at 18:56 UTC

    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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://656665]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-18 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found