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