#!/usr/bin/perl
use strict;
use Tk;
use Tk::LabFrame;
use File::Basename;
# *****************************************************************************
# ** Generiere HAUPTMENÜ ******************************************************
# *****************************************************************************
my $mw = MainWindow->new;
$mw->title("Ein TEST mit LISTBOX");
# *****************************************************************************
# ** Generiere Menü AUSWAHL DES DIRECTORIES ***********************************
# *****************************************************************************
my $laden = $mw->LabFrame(-label=>'[ 1--> Auswahl des Directories ]', -labelside=>'acrosstop')
->pack (-side =>'top', -expand=>1, -fill=>'x');
my $laden_button = $laden->Button(-text=>'Auswählen', -command=> \&Load_Path)
->pack (-side=>'left', -expand=>0, -fill=>'none');
my $laden_entry = $laden->Entry(-width=>100)
->pack (-side=>'left', -expand=>1, -fill=>'x');
# *****************************************************************************
# ** Generiere LISTBOX und BUTTONS ********************************************
# *****************************************************************************
my $listbox_frame = $mw->LabFrame(-label =>'[ 2--> Programme-Auswählen ]',
-labelside =>'acrosstop')
->pack (-side =>'top',
-expand=>'1',
-fill =>'x');
my $Auswahl_Liste = $listbox_frame->Listbox("width" => 70,
"height" => 5,
-selectmode => 'extended')
->pack(-side => 'left');
my $doit_btn = $listbox_frame->Button(-text =>'Ausgewählte Programme ausführen',
-command => \&Run_Perl_Prog)
->pack(-side =>'left', -expand=>0);
my $Select_All = $listbox_frame->Button(-text =>'Alles auswählen',
-command => sub { $Auswahl_Liste->selectionSet(0, 'end');})
->pack(-side =>'left', -expand=>0);
my $De_Select_All = $listbox_frame->Button(-text =>'Alles abwählen',
-command => sub { $Auswahl_Liste->selectionClear(0, 'end');})
->pack(-side =>'left', -expand=>0);
MainLoop();
# *****************************************************************************
# ** Sub LOAD PATH ************************************************************
# *****************************************************************************
sub Load_Path {
my $file_typ = [
['PERL Program', '.pl' ],
['All Files', '*' ],
];
my $dn = $mw->getOpenFile(-filetypes=>$file_typ);
my $file = $dn;
my $dn = dirname($file);
if (defined $dn and $dn ne '') {
$laden_entry->delete(0, 'end');
$laden_entry->insert('end', $dn);
my @files = glob($dn.'/*.pl');
$_ = basename($_) for(@files); # <---Nur FILE NAME übrig lassen.
$Auswahl_Liste->delete(0, 'end')
if(@files);
$Auswahl_Liste->insert('end', @files)
}
}
# *****************************************************************************
# ** Sub Run_Perl_Prog ********************************************************
# *****************************************************************************
sub Run_Perl_Prog {
my $Get_Path = $laden_entry->get();
my $Get_File_Name = $Auswahl_Liste->get($Auswahl_Liste->curselection());
my $slash = "/";
if(!$Get_Path || $Get_Path eq ''){
$mw->messageBox(-message=> " Zuerst ein Programm auswählen.",
-type => "OK"),
return 1;
}
my $tmp_1 = "$Get_Path$slash$Get_File_Name";
my $tmp_2 = qx($^X $tmp_1);
}
# *****************************************************************************
# ** Info-Fenster *************************************************************
# *****************************************************************************
sub leeres_info_fenster {
my $popup = $mw->Dialog(
-popover => $mw,
-title => 'Info Fenster',
-bitmap => 'Tk',
-default_button => 'OK',
-buttons => ['OK'],
-text => "Diese Funktion ist im Moment nicht implementiert. \n".
" \n".
"Bis später. \n".
" \n".
"Danke.",
);
$popup->resizable('no', 'no');
$popup->Show();
}