use strict; use warnings; use Tk; my $mw = new MainWindow; $mw->geometry("420x150"); my $input_frame = $mw->Frame()->pack(-fill => 'x'); my $output_frame = $mw->Frame()->pack(-fill => 'x'); my $process_frame = $mw->Frame()->pack(-fill => 'x'); $input_frame->Label(-text => ' Input: ')->pack(-side => 'left'); my $inputfile_entry = $input_frame->Entry(-width => 50)->pack(-side => 'left'); $input_frame->Button(-text => ' suchen ',-command => [\&getFile, 'INPUT', $mw, $inputfile_entry])->pack(-side => 'left'); $output_frame->Label(-text => ' Output:')->pack(-side => 'left'); my $outputfile_entry = $output_frame->Entry(-width => 50)->pack(-side => 'left'); $output_frame->Button(-text => ' definieren',-command => [\&getFile, 'OUTPUT', $mw, $outputfile_entry])->pack(-side => 'left'); my $listbox = $process_frame->Listbox(-height => 200)->pack(-fill => 'both'); my $scroll = $listbox->Scrollbar(-command => [ 'yview', $listbox ]); $listbox->configure(-yscrollcommand => [ 'set', $scroll ]);$scroll->pack(-side => 'right', -fill => 'y', ); $process_frame->Button(-text => 'Zeilennummerierung hinzufügen',-command => [\&addLinenumbers, $mw, $inputfile_entry, $listbox])->pack(-side => 'left'); $process_frame->Button(-text => 'Schreibe Ausgabedatei',-command => [\&writeFile, $mw, $outputfile_entry, $listbox])->pack(-side => 'left'); $process_frame->Button(-text => 'Script beenden',-command => sub { exit })->pack(-side => 'left'); MainLoop(); my @types = (["Textdatei", ['.txt']]); sub getFile { my($action, $datAuswahl, $entry) = @_; my($filename)=""; #my $filetypes = [ ['Textfiles', ['.txt'] ] ]; if($action eq 'INPUT') { $filename = $datAuswahl->getOpenFile(-filetypes => \@types, -defaultextension => '.txt',-title => 'Select inputfile...'); } elsif($action eq 'OUTPUT') { $filename = $datAuswahl->getSaveFile(-filetypes => \@types, -defaultextension => '.txt',-title => 'Select outputfile...'); } else { warn "getFile(), no action specified!\n"; } if($filename ne '') { $entry->delete(0, 'end'); $entry->insert(0, $filename); } } ....