1
我正在开发一个使用Perl的Tk模块的桌面客户端。我有一个按钮可以打开特定任务的目录。但是我面临的问题是它关闭了我不想要的Perl接口。浏览目录中的Perl Tk窗口自动关闭
下面是实现逻辑目录打开子:我通过调用这个子
sub open_directory {
my $directory = shift;
print "comes here atleast for $directory";
if ($^O eq 'MSWin32') {
exec "start $directory";
}
else {
die "cannot open folder on your system: $^O";
}
}
:
sub second_window{
my $row = 0;
$mw2 = new MainWindow;
#Loop for listing taskname,path and browse button for all tasks of a region
for my $i(1..$#tasks_region_wise){
$row = $row+1;
$frame_table-> Label(-text=>$sno+$i,-font=>"calibri")->grid(-row=>$row,-column=>0,-sticky=>'w');
$frame_table-> Label(-text=>$tasks_region_wise[$i][2],-font=>"calibri")->grid(-row=>$row,-column=>1,-sticky=>'w');
$frame_table-> Label(-text=>$tasks_region_wise[$i][3],-font=>"calibri")->grid(-row=>$row,-column=>2,-sticky=>'w');
#Calling that sub in the below line:
$frame_table->Button(-text => 'Browse',-relief =>'raised',-font=>"calibri",-command => [\&open_directory, $tasks_region_wise[$i][3]],-activebackground=>'green',)->grid(-row=>$row,-column=>3);
$frame_table->Button(-text => 'Execute',-relief =>'raised',-font=>"calibri",-command => [\&open_directory, $tasks_region_wise[$i][4]],-activebackground=>'green',)->grid(-row=>$row,-column=>4);
$frame_table->Button(-text => 'Detail',-relief =>'raised',-font=>"calibri",-command => [\&popupBox, $tasks_region_wise[$i][2],$tasks_region_wise[$i][5]],-activebackground=>'green',)->grid(-row=>$row,-column=>5);
}
$frame_table->Label()->grid(-row=>++$row);
$frame_table->Button(-text => 'Back',-relief =>'raised',-font=>"calibri",-command => \&back,-activebackground=>'green',)->grid(-row=>++$row,-columnspan=>4);
MainLoop;
}
它正确地打开文件资源管理器窗口,但关闭了Perl接口。
我认为这个问题是'exec'调用,它用一个新的替换当前正在运行的可执行文件。 – ulix
感谢那个@ulix,我已经通过使用系统函数而不是exec调用来解决这个问题。 – Mohit