Hello Monks,

I'm not sure what wrong I'm doing. Here's a piece of code that demonstrates the problem I'm facing.

use Tk::Tree; my $mw = MainWindow->new; my $tree = $mw->ScrlTree(-indicator=>1, -browsecmd=>\&abba_browse,) ->pack(-fill => 'both', -expand => 1); my $styleref_select_parent = $tree->ItemStyle('imagetext', -stylename => 'stylename_select_parent', -selectbackground=>'cyan', -selectforeground=>'blue', -font=> [-family => 'Linotype Birka', -size => 20, -weight => 'bold', -slant => 'roman', -underline => 1, -overstrike => 1]); my $styleref_select_child = $tree->ItemStyle('imagetext', -stylename => 'stylename_select_child', -selectbackground=>'cyan', -selectforeground=>'red', -font=> [-family => 'Linotype Birka', -size => 10, -weight => 'bold', -slant => 'roman', -underline => 0, -overstrike => 0]); $tree->add('ABC', -text => 'Text is: ABC', -state=>'normal'); $tree->add('ABC.def', -text => 'Text is: def', -state=>'normal'); $tree->add('ABC.def.ghi', -text => 'Text is: ghi', -state=>'normal'); $tree->setmode(); $tree->close('ABC.def'); my $tree_element; MainLoop; sub abba_browse { $tree_element = $tree->info('selection')->[0]; if ($tree_element eq 'ABC') { $tree->entryconfigure($tree->info('selection'), -style=>$styleref_select_parent); } else { $tree->entryconfigure($tree->info('selection'), -style=>$styleref_select_child); } }

Question 1:
        When I click on the parent entry 'Text is ABC', the ItemStyle configured for this entry doesn't get applied. i.e. while the  -selectbackground doesn't work at all, the values of the  -font option applied are those configured for the child . Why is this so ?

Question 2:
        In the code if I move the declaration for  $styleref_select_parent past that of  $styleref_select_child then only those of the parent are applied to that of child as well. Is it then that only the last declaration which sets the  -font option is considered ?

Question 3:
        Just like we can configure the font for each of the display item in the tree via the -font option, is there a way to configure the size of the indicator in tandem with font for the text entries in the tree ?


BTW: I'm using,
        Strawberry Perl version: 5.16.3
        ItemStyle.pm version: 4.004
        Tree.pm version: 4.72

Many Thanks

In reply to A question on using Tk::ItemStyle in Tk::Tree by Anonymous Monk

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.