Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: A question on using Tk::ItemStyle in Tk::Tree

by Khen1950fx (Canon)
on Oct 31, 2014 at 10:38 UTC ( #1105715=note: print w/replies, xml ) Need Help??


in reply to A question on using Tk::ItemStyle in Tk::Tree

Incorporating the advice of Loops and choroba, I added:
$mw->after( 'idle', [ configure => $styleref_select_parent, -background => 'cyan', ]);
That'll start the cyan background. Give it a try.
#!/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
    Hi Ken,

    Thank you for your response to my query. As I'm new to perl, can you please explain me little bit about what the following construct you added does ?

    $mw->after( 'idle', [ configure => $styleref_select_parent, -background => 'cyan', ]);
        I referred to Mastering Perl/Tk book(Oreilly Press), but I could not find anything being talked about this method named: after.
    1. under what circumstances is this construct useful?
    2. Also, Tk::Widget doesn't have any such method at all. So how this method gets inherited by Tk::Widget class?
    3. The anonymous array passed as second parameter suprisingly has no hyphen prefixing the configure option either.
    4. I was wondering if you have any answers for me to Question: 3 in the original post. (about the size of the font applied to + - indicators as well)

      Please let me know.
      Thanks again,
      Tk::after
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        choroba,

        Thanks for pointing me to this Tk::after. However, I must honestly admit that I'm having difficulty in understanding the docs.

        Firstly, the after method has only two forms.
        1. after(*ms)
        2. after(*ms,*callback)
            In both forms the first parameter is time delay and this should be specified in milliseconds. But Khen1950fx's construct specifies a string 'idle'

            Secondly, the second parameter is the callback whose execution has to be delayed. But in Khen1950fx's construct the method after is called on an instance of MainWindow and does not specify any name of the callback method whose execution is to be delayed.

        But fundamentally speaking though, how does delaying the execution of a callback get helpful?

        I'm unable to find any other docs on this. So please let me know. Thanks in advance

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1105715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2019-05-26 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (153 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!