Hello All, I'm trying to write a script using TK and ran in to a problem.
I need to have the script running and watching a <FILE HANDLE> at the same time. The window is built useing a 'TEXT' widget. I'm wanting to have a file watched and when a NEW line appears in the <FILE> to have the new $_ displayed in the text box.
Any suggestions and or examples would be GREATLY appreciated. Below is what I'm working with now.
use Tk;
$input = text_in;
open INPUT, $input or die "Cannot open $input for read :$!";
my $mw = MainWindow->new();
$mw->Label(-text => 'Members Listing:')->pack();
my $listbox = $mw->Scrolled('Listbox',
-width => 35,
-height => 5,
-scrollbars => 'e')->pack();
$listbox->insert('end', 'John Coltrane', 'Coleman Hawkins',
'Dexter Gordon', 'Charlie Parker', 'Lester Young',
'Ben Webster', 'Charlie Parker', 'Lester Young');
$mw->Label(-text => 'Message Out:')->pack();
my $text_out = $mw->Text(-width => 35,-height => 5)->pack();
my $text_out_box = $text_out->Scrolled('Text',
-width => 30,
-height => 5,
-scrollbars => 'e')->pack();
$mw->Label(-text => 'Message In:')->pack();
my $text_in = $mw->Text(-width => 35,-height =>5)->pack();
my $text_in_box = $text_in->Scrolled('Text',
-width => 30,
-height => 5,
-scrollbars => 'e')->pack();
my $bottom_frame = $mw->Frame()->pack(-side => 'bottom',-pady => 5);
$bottom_frame->Button(-text => 'Get Line',
-command => \&check)->pack(-side => 'left');
MainLoop;
$text_in->repeat(3000, &check);
sub check {
#chomp($line_in = <INPUT>);
$line_in = <INPUT>;
$text_in_box->configure(-state => 'normal');
$text_in_box->insert('end', $line_in);
$text_in_box->configure(-state => 'disabled');}
Thanks in Advance.
I need to have the script running and watching a <FILE HANDLE> at the same time. The window is built useing a 'TEXT' widget. I'm wanting to have a file watched and when a NEW line appears in the <FILE> to have the new $_ displayed in the text box.
Any suggestions and or examples would be GREATLY appreciated. Below is what I'm working with now.
use Tk;
$input = text_in;
open INPUT, $input or die "Cannot open $input for read :$!";
my $mw = MainWindow->new();
$mw->Label(-text => 'Members Listing:')->pack();
my $listbox = $mw->Scrolled('Listbox',
-width => 35,
-height => 5,
-scrollbars => 'e')->pack();
$listbox->insert('end', 'John Coltrane', 'Coleman Hawkins',
'Dexter Gordon', 'Charlie Parker', 'Lester Young',
'Ben Webster', 'Charlie Parker', 'Lester Young');
$mw->Label(-text => 'Message Out:')->pack();
my $text_out = $mw->Text(-width => 35,-height => 5)->pack();
my $text_out_box = $text_out->Scrolled('Text',
-width => 30,
-height => 5,
-scrollbars => 'e')->pack();
$mw->Label(-text => 'Message In:')->pack();
my $text_in = $mw->Text(-width => 35,-height =>5)->pack();
my $text_in_box = $text_in->Scrolled('Text',
-width => 30,
-height => 5,
-scrollbars => 'e')->pack();
my $bottom_frame = $mw->Frame()->pack(-side => 'bottom',-pady => 5);
$bottom_frame->Button(-text => 'Get Line',
-command => \&check)->pack(-side => 'left');
MainLoop;
$text_in->repeat(3000, &check);
sub check {
#chomp($line_in = <INPUT>);
$line_in = <INPUT>;
$text_in_box->configure(-state => 'normal');
$text_in_box->insert('end', $line_in);
$text_in_box->configure(-state => 'disabled');}
Thanks in Advance.