perlquestion
Anonymous Monk
Hello Monks,<br>
<p>
I'm not sure what wrong I'm doing. Here's a piece of code that demonstrates the problem I'm facing.
</p>
<code>
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);
}
}
</code>
<p>
Question 1:<br>
        When I click on the parent entry 'Text is ABC', the <code>ItemStyle</code> configured for this entry doesn't get applied. i.e. while the <code> -selectbackground</code> doesn't work at all, the values of the <code> -font </code> option applied are those configured for the child . Why is this so ?
<br>
<br>
Question 2:<br>
        In the code if I move the declaration for <code> $styleref_select_parent </code> past that of <code> $styleref_select_child </code> 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 <code> -font </code> option is considered ?
<br><br>
Question 3:<br>
        Just like we can configure the font for each of the display item in the tree via the <code>-font</code> option, is there a way to configure the size of the indicator in tandem with font for the text entries in the tree ?
</p>
<br>
BTW: I'm using,<br>
        Strawberry Perl version: 5.16.3<br>
        ItemStyle.pm version: 4.004<br>
        Tree.pm version: 4.72
<br><br>
Many Thanks
7