开发者

GUI freeze - Perl Tk

开发者 https://www.devze.com 2023-03-05 22:26 出处:网络
I have developed a small application using Perl/Tk. The application will fetch data from the web when on开发者_JS百科e of the buttons in the application is pressed. But the problem is that the GUI get

I have developed a small application using Perl/Tk. The application will fetch data from the web when on开发者_JS百科e 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号