in reply to Re: (tye)Re: TK Problem (me again)
in thread TK Problem (me again)

(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.