Hi,
the code below runs fine on my active state 5.8 installation at work but barfs with the error:
"at /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Tk/ItemStyle.pm line 21."
under RH9.0, Perl 5.8.0 (fresh install from source) and Tk804.024. Interestingly if I only specify the background colour style it works fine. Any-one have any clues? Thanks.
#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::HList;
use Tk::ItemStyle;
use Tk::Label;
my $mw = MainWindow->new();
my $label = $mw->Label(-width=>15);
my $hlist = $mw->HList(
-itemtype => 'text',
-separator => '/',
-selectmode => 'single',
-browsecmd => sub {
my $file = shift;
$label->configure(-text=>$file);
}
);
my %priorities = (
1 => { text => 'Highest', colour => 'red' },
2 => { text => 'High', colour => 'orange' },
3 => { text => 'Medium', colour => 'darkgreen' },
4 => { text => 'Low', colour => 'blue' },
);
for my $int (1..4){
$priorities{$int}->{style} = $hlist->ItemStyle('text',
-foreground => $priorities{$int}->{colour},
-background => 'white',
-selectbackground => '#0A246A',
-selectforeground => 'white',
);
}
foreach ( qw(/ /home /home/ioi /home/foo /usr /usr/lib) ) {
$hlist->add($_, -text=>$_, -style=>$priorities{1}->{style});
}
$hlist->pack;
$label->pack;
MainLoop;
Most of the code above is from the Tk::HList manapge, I used it to work up the test case :)
--
Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.