It gets to be a real juggling act when you try to finesse the colors in these lists. You always run into a situation where one setting interferes with another. You just need to experiment. Try this:
#!/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();

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re^3: Tk::HList selectionClear background problem by zentara
in thread Tk::HList selectionClear background problem by gri6507

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.