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

I'm using something like the following Perl/Tk script to get data from a server. Problem is, on clicking the button the Tk window locks up and none of the messages get posted to the display; even the button doesn't get 'released' until after the Telnet session has closed.
$Btn_1 = $Frame_1 ->Button(-text => "Get details", -command => sub{Get_Item_Details ()} ); $Btn_1 ->pack; sub Get_Item_Details () { $Label_4 -> configure(-text => "Starting Telnet . . ."); # Start TELNET dialog; $Label_4 -> configure(-text => "Sent User Name . . ."); # User Procedure; $Label_4 -> configure(-text => "Sent Password . . ."); # Password Procedure # data received is OK . . . et cetera ; #close TELNET session ; }
The Telnet session works great, but the seizure just doesn't look very professional. Any help/suggestions greatly appreciated. Clachair

Replies are listed 'Best First'.
Re: Perl/Tk question
by Jouke (Curate) on Apr 24, 2001 at 13:33 UTC
    I noticed similar behaviour when playing a sound on an event. Everything locks up until the callback is finished. I'm going (haven't tried yet) to fork that callback so it returns to the mainloop earlier.



    Jouke Visser, Perl 'Adept'
Re: Perl/Tk question
by TheoPetersen (Priest) on Apr 24, 2001 at 18:15 UTC
    You need to return control to Tk so that it can change the text, redraw the buttons and so on. Read the pod for Tk::Widget and search for the update and idletasks methods.
      Thanks Theo:

      All it seemed to need was the 'update' routine.

      Many thanks,

      Clachair.