(Caveat: I've never used Tk in my life, but I think I understand what's going on here by way of context. Take this with a grain of salt.) I don't think you want while (<LOG>) in there. You get to &insert_text when Tk says the filehandle has something waiting to be read. It's probably safe to assume that the amount of data waiting is at least a single line, so you can probably use <LOG> to get it, but don't just turn it into a while loop, or else your function is going to remain "in control" until LOG is depleted (which will be never), and Tk will never have the chance to re-enter its own event loop. Perhaps you want something more like this:
sub insert_text { local($_) = <LOG>; # process 1 waiting line if (/(CRITICAL|MAJOR)/) { $text->insert('end', $_, $1); } else { $text->insert('end', $_); } }
If you have 10 lines waiting from LOG, let Tk call your function 10 times. (Unread data still counts as a readable event, I would suspect, but I am assuming Tk implements this using select.)

You'll have to do something else entirely (is there an 'eof' filevent? an error one?) I suspect to set yourself up to clear the readable event for that file handle, unless insert_text will be called when eof(LOG) is true.


In reply to Re: Re: Re: TK Problem (me again) by Fastolfe
in thread TK Problem (me again) by locked_user mr_leisure

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.