- 论坛徽章:
- 0
|
#part 1
use Tk;
use Encode;
use threads;
threads->create('manageThread')->detach;
sub manageThread{
while(1){
print "等待执行的代码块\n";
sleep 1;
}
}
my $mw = MainWindow->new;
$mw->title(decode("gb2312","网络"));
my $enterStr = $mw->Entry(-width => 30,-font => [-size => 12])->pack(-side => 'left');
$mw->Button(-text => decode("gb2312","请输入要查找的关键字"),-font => [-size => 10], -command =>sub {
my $string = $enterStr->get();
print $string,"\n";#我想得到我输入的信息。
})->pack(-side => 'left');
MainLoop;
__END__
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
#part 2
use encoding "euc-cn";
use Tk;
use threads;
threads->create('manageThread')->detach;
sub manageThread{
while(1){
print "等待执行的代码块\n";
sleep 1;
}
}
my $mw = MainWindow->new;
$mw->title("网络");
my $enterStr = $mw->Entry(-width => 30,-font => [-size => 12])->pack(-side => 'left');
$mw->Button(-text => "请输入要查找的关键字",-font => [-size => 10], -command =>sub {
my $string = $enterStr->get();
print $string,"\n";#我想得到我输入的信息。
})->pack(-side => 'left');
MainLoop;
#用第一部分的代码 执行 $enterStr->get();显示不出我输出的汉字,是乱码。
#
#当我换成第二部分的代码,程序出错了,执行 threads->create('manageThread')->detach;#就出错。 我的目的是这个线程是必需开的,但是我又要通过 $enterStr->get();得到输入的数
#据。请大家指点,谢谢! |
|