in reply to PerlTk Busy vs. update

$statuslabel->update should work.

Replies are listed 'Best First'.
Re^2: PerlTk Busy vs. update
by eserte (Deacon) on Jul 02, 2004 at 08:37 UTC
    $statuslabel->update is the same as Tk->update, i.e. it would update all Tk widgets in the application, not only $statuslabel.
Re^2: PerlTk Busy vs. update
by Anonymous Monk on Jul 02, 2004 at 06:58 UTC
    I thought so too, but I seem to be able to hit my Quit button despite the fact that I'm seeing the hourglass (universal sign for "you shouldn't be able to hit the Quit button now")

    Any thoughts on the merits of idletasks() vs update() ?

      The difference is that idletasks() only serves IDLE_EVENTS (for example those callbacks defined with the afterIdle method), while update() serves all events. When in doubt use update().
      If I've got this right, you're setting $main->Busy, calling $label->update, and seeing responses to events - like a buttonclick on another widget - occur when the child widget performs the update. Are you setting -recurse => 1 in the call to Busy?

      (I always set that, except in exceptional circumstances, and so ass-u-me-d that $child->update would not affect $otherchild.)

        You've got it right, and I am setting -recurse=>1 but as pointed out below, the update acts globally.

        Does anyone know what the behavior of setting (un)Busy an already (un)Busy widget is "supposed" to be?

        I think this might be my problem.

      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.

        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?