in reply to A question on using Tk::ItemStyle in Tk::Tree
Incorporating the advice of Loops and choroba, I added:
That'll start the cyan background. Give it a try.$mw->after( 'idle', [ configure => $styleref_select_parent, -background => 'cyan', ]);
#!/usr/bin/perl -l use strict; use warnings; use Tk; use Tk::Tree; require Tk::ItemStyle; my $mw = new MainWindow; 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', -foreground => 'dark blue', -background => 'cyan', -font => [ -family => 'Linotype Birka', -size => '-10', -weight => 'bold', -slant => 'roman', -underline => 0, -overstrike => 0 ] ); my $styleref_select_child = $tree->ItemStyle( 'imagetext', -stylename => 'stylename_select_child', -foreground => 'red', -background => 'cyan', -font => [ -family => 'Linotype Birka', -size => '20', -weight => 'bold', -slant => 'roman', -underline => 1, -overstrike => 1 ], ); $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(); $mw->after( 'idle', [ configure => $styleref_select_parent, -background => 'cyan' ], ); MainLoop; sub abba_browse { my $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 ); } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: A question on using Tk::ItemStyle in Tk::Tree
by Anonymous Monk on Nov 01, 2014 at 05:13 UTC | |
by choroba (Cardinal) on Nov 01, 2014 at 08:07 UTC | |
by Anonymous Monk on Nov 01, 2014 at 09:49 UTC | |
by Loops (Curate) on Nov 01, 2014 at 11:47 UTC | |
by Anonymous Monk on Nov 05, 2014 at 08:13 UTC | |
|
In Section
Seekers of Perl Wisdom