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); }

Rich36
There's more than one way to screw it up...


In reply to Re: Redraw windows by Rich36
in thread Redraw windows by NaSe77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.