#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Tree; use Tk::ItemStyle; my $fgcolor = "#000000"; # foreground color my $bgcolor = "#FFFFFF"; # background color my $text_font = 'helvetica 12'; # Body 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=>'white', -highlightcolor=>'white', -highlightthickness => 0, -drawbranch=>0, -browsecmd=>sub { foreach ($tree->selectionGet) { if (/\./) { # do not allow selection of top level i +tems $tree->configure(-selectbackground => 'blue') }else{ # $tree->selectionClear($_); $tree->configure(-selectbackground => 'white') } } $tree->anchorClear() } )->pack(-side=>'top', -fill=>'both', -expand=>1); $tree->columnWidth(0, -char, 90); #get full row color # create style for different colors my $S1 = $tree->ItemStyle( 'imagetext', -foreground => 'black', -background => 'white', -selectforeground =>'black', -selectbackground =>'white', ); my $S2 = $tree->ItemStyle( 'imagetext', -foreground => 'black', -background => 'white', -selectforeground =>'yellow', -selectbackground =>'blue', ); for my $top ( 1 .. 3) { $tree->add( $top, -text => $top, -style=> $S1 ); for ( 'A' .. 'C') { $tree->add( "$top.$_", -text => "$_", -style=> $S2 ); } } MainLoop();
In reply to Re^3: Tk::HList selectionClear background problem
by zentara
in thread Tk::HList selectionClear background problem
by gri6507
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |