Search code examples
perlperltk

GUI freeze - Perl Tk


I have developed a small application using Perl/Tk. The application will fetch data from the web when one of the buttons in the application is pressed. But the problem is that the GUI gets hang until control is returned. I know this is due to delay so the main window goes unresponsive. I used the update() function but still the problem persists. So I google around and came to know we can use threads to overcome this problem. But I am not sure how to use threads in Perl/Tk. Here is my sample code

use warnings;
use Tk;

my $mw = new MainWindow;

my $button = $mw -> Button(-text => "Fetch", 
        -command => \&FetchData)
    -> pack();
MainLoop;

sub FetchData
{
//Fetching data from Web
}

Thanks in advance.


Solution

  • Have never tried this, but this PerlMonks thread from 2008 "Perl Tk and Threads" might help you get going.