in reply to Re^2: PerlTk Busy vs. update
in thread PerlTk Busy vs. update

Idletasks will change a label, but not perform other needed tasks. For example:
#!perl use strict; use warnings; use Tk; my $top = MainWindow->new(); my $txt = $top->Text->pack; for my $t ('a' .. 'z') { $txt->insert('end', $t x 40 . "\n"); } my $lbltxt = "wowowowowowowowowowowowowowo"; my $label = $top->Label(-textvariable => \$lbltxt)->pack; my $button = $top->Button(-text => "Die", -command => sub { exit; })-> +pack; $top->update; #$top->Busy(-recurse => 1); # use $top->Busy; # drop sleep 8; $lbltxt = "updatedupdated"; #$label->update; # use $label->idletasks; # drop sleep 8; $txt->delete('1.0','end'); $top->Unbusy; Tk::MainLoop;
Run this, click on the "Die" button as soon as the window appears. After the first sleep, the label is changed, but since the new text is of shorter length several "wowo" characters remain on either side of "updated". After the 2nd sleep and the Unbusy, the "Die" event occurs and the program exits.

Comment out the "drop" lines and uncomment the "use" lines.

Run now, click "Die" before the label changes. This time there are no leftover characters, and the "Die" event is discarded. After the Unbusy the program continues.

Replies are listed 'Best First'.
Re^4: PerlTk Busy vs. update
by Anonymous Monk on Jul 02, 2004 at 18:24 UTC
    I get different behavior than you describe (running on my Sun box). There are no "leftover characters" either way, but as noted the "Die" event is only discarded if -recurse=>1 is set. Perhaps this is a portability issue?
      That seems to be the case - running it on a Linux box here leaves no leftovers either. With recurse, the "Die" event is discarded during the ->update, or after the Unbusy with idletasks.