use strict; use warnings; use Tk; use Tk::Tree; my $fgcolor = "#000000"; # foreground color my $bgcolor = "#FFFFFF"; # background color my $list_highlight_color = "#0099FF"; # list highlight color my $text_font = 'helvetica 12'; # Body text font my $title_font = 'helvetica 12 bold'; # Title text font my $mw = MainWindow->new(); $mw->optionAdd("*background", $bgcolor); $mw->optionAdd("*foreground", $fgcolor); $mw->optionAdd("*rotext*font", $text_font); $mw->optionAdd("*tree*font", $text_font); $mw->optionAdd("*entry*font", $text_font); my $tree; $tree = $mw->Scrolled('Tree', -font=>$text_font, -scrollbars=>'ose', -selectmode=>'extended', -selectbackground=>$list_highlight_color, -highlightcolor=>$bgcolor, -drawbranch=>0, -browsecmd=>sub { foreach ($tree->selectionGet) { unless (/\./) { # do not allow selection of top level items $tree->selectionClear($_); } } })->pack(-side=>'top', -fill=>'both', -expand=>1); for my $top ( 1 .. 3) { $tree->add( $top, -text => $top ); for ( 'A' .. 'C') { $tree->add( "$top.$_", -text => "$_" ); } } MainLoop();