Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: Colorize rows of Tk::Tree/Hlist
by AgentM (Curate) on Mar 16, 2001 at 02:01 UTC
    Could it be an error in your version of TK? Make sure you have the latest version. Could this be a bug in just the Winduz version? Try the same code on a different platform. If you find a bug, then, by all means, report it to the owner of the library!
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.