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

OK, I am new to PERL\TK and I am writing a program that will prescreen and wipe out spams from my email box before bothering to download them. I would like to have a window update during the loop so I can gage progress. It seems that the information buffers until the lop is over and then updates. Got any suggestions? The below would check the connection status. it too seems to buffer and then post after the sub completes.
# Check Connection sub connectInfo{ infoCheck(); #getCfgInfo(); $TA -> delete("0.0", "end"); #settings(); $SA -> configure( -text => ''); $SA -> configure( -text => 'Configuration Retrived'); use Net::POP3; my $res = my $pop = Net::POP3->new($popServ, Debug => 1, Timeout = +> 60) or die "Can't Connect: $!\n"; $TA -> insert('end', "Server Available : $popServ\n", reset) if +($res); $SA -> configure( -text => 'Server Check'); $res = ""; $res = $pop->user($popUser); # or die "Can't Authenticate User: $! +\n";; $TA -> insert('end', "User Logged On : Successful\n", reset) + if ($res == 1); $TA -> insert('end', "User Logged On : NOT successful\n", rese +t) unless ($res == 1); $SA -> configure( -text => 'User Check'); $res = ""; $res = $pop->pass($popPass); # or die "Can't Authenticate Pass: $! +\n";; if ($res > 0) { $TA -> insert('end', "Password Author. : Successful\nServer +Responding : $res Messages Waiting\n") ; } else { $TA -> insert('end', "Password Author. : NOT successful ($re +s)\n"); } $SA -> configure( -text => 'Password Check'); $res = ""; $res = $pop->quit(); $TA -> insert('end', "Log Off Server : Clean Logoff\n\n") +if ($res == 1); $TA -> insert('end', "Log Off Server : Broke Connection\n\n") +unless ($res == 1); $TA -> insert('end', "System Ready\n\n"); $SA -> configure( -text => 'Log off'); }

Replies are listed 'Best First'.
•Re: Updating a TK window during a sub
by merlyn (Sage) on May 04, 2004 at 20:25 UTC
      That got it... very cool, thank you all, wise and knowning monks for the blessing of your wisdom...
Re: Updating a TK window during a sub
by Ven'Tatsu (Deacon) on May 04, 2004 at 20:16 UTC
    You can call $widget->update or $widget->idletasks to update Tk's windows. Take a look at the Tk::Widget docs to see which would fit better in your situation.
Re: Updating a TK window during a sub
by periapt (Hermit) on May 04, 2004 at 20:16 UTC
    Basically, if you have defined a counter or some other tracking variable, you can pass that variable into the processing subroutine (along with a reference to the main window) and change that reference as you go. To post the change to the GUI, issue the update command to the main window. ex $mw->update (assuming, $mw is the reference created by Mainwindow->new command).