Hello, didn't get any response on my last query. So I'm trying again and will be more suscinct. 8~) When colorizing individual rows in a Tk::Tree, the SELECTED row will color to the borders of the fixed window but the NON SELECTED rows will not. This looks real ugly. 1. Is there anyway to fix it? I've hit several lists and it seems no one knows. 2. Is there another graphics package for PERL that can handle this? Below are two examples that show this ugly results of tree and colorization of rows:
.
SINGLECOLUMNTREE.pl---------------------------------------
#!/usr/bin/perl -w use strict; # Import modules. # use Tk; use Tk::Tree; use Tk::ItemStyle; use Tk::Adjuster; # Create a new main window. # my $top = new MainWindow( -title => "Tree" ); my $adj = $top->Adjuster(); # Create a scrollable Tree widget. # my $tree = $top->Scrolled( 'Tree', -separator => '/', -scrollbars => 'osoe', -selectbackground => 'blue', # -selectmode=>'extended', -header=>1, -height => 20, -columns=>1, -width => 30)->pack( -side => 'top', -anchor=>'n', -expand=>'1', -fill => 'both'); $tree->packAdjust(-side => 'left', -fill => 'both', -delay => 1); $tree->header("create",0,-text=>"Food "); my @colors; $colors[1] = $tree->ItemStyle('imagetext', -foreground=>'white', -activebackground=>'black', -background=>'#cc0000', -font => "Helv 7 bold", -wraplength => '40', # -tabs => 'right' # -spacing2 => 6 ); $colors[2] = $tree->ItemStyle('imagetext', -foreground=>'white', -font => "Helv 7 bold", -background=>'#ff6600' ); $colors[3] = $tree->ItemStyle('imagetext', -foreground=>'black', -font => "Helv 7 bold", -background=>'#ffff00' ); $colors[4] = $tree->ItemStyle('imagetext', -foreground=>'black', -font => "Helv 7 bold", -background=>'#ffff99' ); # Fill the tree with information. # $tree->add("food", -text => "Food", -style=>$colors[1]); $tree->add("food/dairy", -text => "Dairy a", -style=>$colors[1]); $tree->add("food/dairy/milk", -text => "Milk", -style=>$colors[2]); $tree->add("food/dairy/cheese", -text => "Cheese", -style=>$colors[3]); $tree->add("food/dairy/yogurt", -text => "Yogurt", -style=>$colors[4]); $tree->add("food/meat", -text => "Meat", -style=>$colors[1]); $tree->add("food/meat/pork", -text => "Pork", -style=>$colors[2]); $tree->add("food/meat/beef", -text => "Beef", -style=>$colors[3]); $tree->add("food/meat/poultry", -text => "Poultry Big test here", -style=>$colors[4]); $tree->autosetmode(); # Add collapse/expand controls. MainLoop();
MULTICOLUMNTREE.pl---------------------------------------
#!/usr/bin/perl -w use strict; # Import modules. # use Tk; use Tk::Tree; use Tk::ItemStyle; use Tk::Adjuster; # Create a new main window. # my $top = new MainWindow( -title => "Tree" ); $top->geometry("800x600"); my $adj = $top->Adjuster(); # Create a scrollable Tree widget. # my $tree = $top->Scrolled( 'Tree', -separator => '/', -scrollbars => 'osoe', -selectbackground => 'blue', # -selectmode=>'extended', -header=>1, -height => 20, -columns=>2, -width => 30)->pack( -side => 'top', -anchor=>'n', -expand=>'1', -fill => 'both'); $tree->packAdjust(-side => 'left', -fill => 'both', -delay => 1); $tree->header("create",0,-text=>"Food "); $tree->header("create",1,-text=>"Count"); my @colors; $colors[1] = $tree->ItemStyle('imagetext', -foreground=>'white', -activebackground=>'black', -background=>'#cc0000', -font => "Helv 7 bold", -wraplength => '40', -justify => "right" ); $colors[2] = $tree->ItemStyle('imagetext', -foreground=>'white', -font => "Helv 7 bold", -background=>'#ff6600' ); $colors[3] = $tree->ItemStyle('imagetext', -foreground=>'black', -font => "Helv 7 bold", -background=>'#ffff00' ); $colors[4] = $tree->ItemStyle('imagetext', -foreground=>'black', -font => "Helv 7 bold", -background=>'#ffff99' ); # Fill the tree with information. # $tree->add("food", -text => "Food", -style=>$colors[1]); $tree->itemCreate("food",1,-text=>"6",-style=>$colors[1]); $tree->add("food/dairy", -text => "Dairy a", -style=>$colors[1]); $tree->add("food/dairy/milk", -text => "Milk", -style=>$colors[2]); $tree->add("food/dairy/cheese", -text => "Cheese", -style=>$colors[3]); $tree->add("food/dairy/yogurt",-text => "Yogurt", -style=>$colors[4]); $tree->add("food/meat", -text => "Meat", -style=>$colors[1]); $tree->add("food/meat/pork", -text => "Pork", -style=>$colors[2]); $tree->add("food/meat/beef", -text => "Beef", -style=>$colors[3]); $tree->add("food/meat/poultry", -text => "Poultry Big test here", -style=>$colors[4]); $tree->autosetmode(); # Add collapse/expand controls. MainLoop();
Any assistance would be appreciated

In reply to Colorize rows of Tk::Tree/Hlist by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.