2009年8月4日星期二

[PerlChina] Re: 请教 Tk 和 threads

谢谢你的答复
我是想加入 threads的 因为 Tk阻塞
你这次修改完了 threads相当于没加 不是我想要的
而且 这样改完了 dd 和d是一样的 sub
无论如何 很感谢了

On 8月4日, 上午10时40分, langq 235 <langq...@gmail.com> wrote:
> 刚发现,实际上是我太不细心了,把sub d放上来就可以了,顺序问题,应该放在Mainloop上面
>
> use strict;
> use warnings;
> use threads;
> my $cks;
> my $url;
> my $filename;
> my $cks_enter;
> my $url_enter;
> my $fnm_enter;
> sub dd{
> #my $thr1 = threads->new(\&d);
> #$thr1->join;
> d();}
>
> sub d {
> $cks = $cks_enter->get();
> chomp($cks);
> $url = $url_enter->get();
> chomp($url);
> $filename = $fnm_enter->get();
> chomp($filename);
> use LWP::UserAgent;
> my @headers = (
> 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; EN; rv:
> 1.9.0.11) Gecko/2009060215 Firefox/3.5',
> 'cookie' => "$cks",
> );
> my $ua = LWP::UserAgent->new();
> my $req = $ua->get($url,@headers);
> my $cont = $req->content;
> open PIC, ">$filename";
> binmode(PIC);
> print PIC "$cont\n";
> close PIC;}
>
> use Tk;
> my $mw = MainWindow->new();
> $mw->resizable( 0,0 );
> $mw->title("test");
> my $frame = $mw->Frame(-borderwidth => 2,-relief => 'groove')->pack();
> my $bttn = $mw->Button(-text => "Down",-command => \&dd)->pack(-side
> => 'left');
> $frame->Label(-text => 'Cookies:')->pack();
> $cks_enter = $frame->Entry(-textvariable => \$cks,-width => 50)->pack
> ();
> $frame->Label(-text => 'URL:')->pack();
> $url_enter = $frame->Entry(-textvariable => \$url)->pack(-expand => 1,
> -fill => 'x');
> $frame->Label(-text => 'Filename:')->pack();
> $fnm_enter = $frame->Entry(-textvariable => \$filename)->pack(-expand
> => 1, -fill => 'x');
> MainLoop;
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: