donato has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I just finishe developing a user app using Tk and now I have to fix one strange behaviour (by strange I mean: that which I do not understand). I have a loop that executes on a button callback and it executes a function and depending on the data returned by the function I have to show some things on the app window. Thing is: when the loop is being executed, and I change the text of a Label object, it does not "change" instantly. It is as if the loop blocks the app (if I put other windows on top of it, it is not redrawn). Here is a piece of the code, edited to fit here:
$err = $SiTef->ExecutaLoopAutorizacao( $SiTef, $params, $data ); while ( $err eq '10000' ) { #print Dumper( $params, $data ); #print "\nRETORNO: $err\n"; if ( $params->{UserMessage} ) { $Status = $params->{Message}; } $err = $SiTef->ExecutaLoopAutorizacao( $SiTef, $params, $data ); }
the GUI has this label:
my $Status; my $lblStatus = $mw->Label(-textvariable=>\$Status)->pack();
Is there something Im not getting about Tk programming, is there an easy way to fix this or should I go somewhere else?
------------------------------- Keep on PERLing the free world. ------donato-------------------

Replies are listed 'Best First'.
Re: Tk behaviour
by jdtoronto (Prior) on Feb 14, 2007 at 16:48 UTC
    To get the GUI to change you usually need to run the update method on the MainWindow,
    $mw->update();
    jdtoronto
      Thank you!!
      jdtoronto++ while (1);
      ------------------------------- Keep on PERLing the free world. ------donato-------------------