greenFox has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk ItemStyle problem on linux
by greenFox (Vicar) on Jun 23, 2003 at 08:34 UTC | |
|
Re: Tk ItemStyle problem on linux
by converter (Priest) on Jun 14, 2003 at 19:58 UTC | |
by greenFox (Vicar) on Jun 15, 2003 at 02:22 UTC | |
by converter (Priest) on Jun 15, 2003 at 02:48 UTC |