#!/usr/bin/perl
use Tk;
use Tie::File;
use Tk::after;
my $liste;
my $liste_font;
my $breite=100; ### Anzahl der abgezeigten Zeichen in der Liste
my $the_selectmode = "extended"; ### "single","multiple","extended"
my $enter;
my @array_file;
my $filename="meinfile.txt";
open (FH, "<$filename" ) || die "Kann $filename nicht oeffnen $! \n";
my $mw = MainWindow->new();
### rahmen fuer Hauptseite
my $frame1 = $mw->Frame(-width=>50, -height=>50, -bg=>"seashell");
my $frame2 = $mw->Frame(-width=>5, -height=>5, -bg=>"grey80");
$liste_font = $mw->fontCreate(-family=>"courier", -size=>7 ); ### zB treffer-Liste
my $liste = $frame1->ScrlListbox(
##-font=>$liste_font,
-setgrid=>1,
-scrollbars=>"se",
-background=>"lemonchiffon3",
-borderwidth=>3,
-highlightthickness=>10,
-height => 30,
-selectforeground=>"blue",
-selectbackground=>"green",
-relief=>"ridge",
-exportselection => 1)->pack(-side=>"right", -expand=>1, -fill=>"both");
my $exitButton = $frame2->Button ( -text=>"Schliessen" ,-command=>"exit" ,-bg=>"red" ,-activebackground=>"red" ,-activeforeground=>"cyan" )->pack(-anchor=>"w" ,-padx=>10 ,-pady=>15 ,-ipady=>10 ,-fill=>"x");
##############################
### Packen der Rahmen auf Hauptseite ############################
$frame1->pack(-side => 'left' ,-expand=>1 ,-fill=>"both");
$frame2->pack(-side => 'right',-expand=>1 );
$frame2->pack(-expand=>1 ,-fill=>"both");
$mw->fileevent(FH, 'readable', [\&refresh_list] );
#$mw->fileevent(FH, readable=>\&refresh_list );
$mw->MainLoop;
#########
sub refresh_list {
my $line;
$liste->delete(0,"end");
if ( $line = <FH> ) {
chomp $line;
$liste->insert(0,$line);
} else {
$mw->fileevent (FH, 'readable', "");
} ## if
} ## refresh_list
############