####
####
.
####
#!/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();
####
#!/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();