What you can do to get a continuous output from a process is tie a filehandle to a ROText box. Below is something that I hacked together just now - it opens a perl script and prints the comment lines to the ROText box. It sets up a file handle (WINDOW) and ties that to the ROText box. The ROText box will update whenever any print is done to that file handle. By placing the functionality of your sub "go" in the "addText" sub and printing to the filehandle WINDOW, the text will be updated continously. You just have to have some kind of event (like the button below) to trigger the callback to the sub.
If you haven't used the ROText box, it functions just like a normal Tk text box, but is read only.
#!/usr/bin/perl use strict; use Tk; use Tk::ROText; ####################################################### # MAIN ####################################################### my $mw = MainWindow->new(-title=>'Tie Test'); my $appROText = $mw->Scrolled('ROText', -relief=>'ridge', -width=>100, + height=>30)->pack(); my $goButton = $mw->Button(-text => 'Add text to window', command=>\&a +ddText)->pack(); tie(*WINDOW, 'Tk::ROText', $appROText); MainLoop; sub addText { open(FILE, "<someapp.pl") or die "Couldn't open file"; while(<FILE>) { print WINDOW $_ if (m/^\#/); } close(FILE); }
In reply to Re: Redraw windows
by Rich36
in thread Redraw windows
by NaSe77
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |