http://qs1969.pair.com?node_id=1106159


in reply to Re^5: A question on using Tk::ItemStyle in Tk::Tree
in thread A question on using Tk::ItemStyle in Tk::Tree

    I was waiting and hoping if choroba would also respond. Anyway, this kind of detailed response from you does help for newbie like me. I had to repeatedly read through your response and hence it took me sometime to go through the after call details you specified.

  1. Now it appears to me that this afterIdle construct,
    $mw->after( 'idle', [configure => $styleref_select_parent, -background => 'cyan' ], );
    in this particular scenario can be replaced by:

     $styleref_select_parent->configure(-background => 'cyan');
    Is my observation correct ?(after all I got the same output) If not, is there any advantage in going for a Tk::After call?

  2. Refering to your last example: As per the docs,

    (on Tk::Callbacks) the callback when using methodname has the syntax,

         ... => ['methodname', args... ] ...

    and the Tk::after method has the syntax
    after(*ms*, *callback*?).
    So how do these fit in to permit the syntax  2000=> configure => $tree
    in your code:
    $mw->after( 2000 => configure => $tree, -background => 'green' ); ?

  3. I'm eagerly trying to get a handle in understanding this afterIdle method. So I chanced to come across the problem Table matrix suspected selected cell discrepancy and the solution to it Tablematrix 'odd' behaviour of mouse and key solved. where the method
    sub brscmd { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; my ($sel, $js); $sel = $t->curselection(); # <-- THE PROBLEM print "@$sel\n"; foreach $js (@$sel) { print "\n[brscmd] actual index <$actual_index> from curselection <$js>\n"; } }
    was replaced by
    sub brscmd { my ($previous_index, $actual_index) = @_; my ($row, $col) = split ',', $actual_index; my ($sel, $js); $t->after( 'idle', # <-- THE SOLUTION sub{ my $sel = $t->curselection(); print "@$sel\n"; foreach $js (@$sel) { print "[brscmd] actual index <$actual_index> from curselection <$js> last_button_key <$last_button_key>\n"; } } ); }
    and things just happen to work fine.

    But I'm unable to grasp the idea behind using  afterIdle call here.

  4. I realize that the number of monks responding to questions on Perl/Tk is generally less than what is comes to other areas of Perl. Since last week the count is again down by 1 after very useful zentara bid adieu to PM.

    So any information monks provide, I say sincerely, will be useful indeed.
    Many Thanks