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.#!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;
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.
In reply to Re^3: PerlTk Busy vs. update
by keszler
in thread PerlTk Busy vs. update
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |