in reply to (tye)Re: TK Problem (me again)
in thread TK Problem (me again)
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: TK Problem (me again)
by danger (Priest) on Jan 05, 2001 at 23:58 UTC | |
Here is a version with fileevent that works (with some problems):
The problem being (on my machine) that it sometimes doesn't update even there is data waiting on the pipe. Even the first time it only gets the first line of the tail, then nothing until another line is added to the file (then it gets the remainder of the tail and the newer line). You could work around this using repeat() to check the file yourself every so often -- here's a quicky example that might suffice for your needs:
| [reply] [d/l] [select] |
|
Re: Re: Re: TK Problem (me again)
by Fastolfe (Vicar) on Jan 05, 2001 at 20:09 UTC | |
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. | [reply] [d/l] [select] |
|
(tye)Re2: TK Problem (me again)
by tye (Sage) on Jan 04, 2001 at 23:22 UTC | |
doesn't do what you want. Perhaps: I was thinking of using nearly your original code inside of insert_lines(), assuming that that code set the default color for new insertions. I guess you'd have to restore the default color in the else clause or at the bottom of the loop (or in a continue block). - tye (but my friends call me "Tye") | [reply] [d/l] [select] |
|
Re: Re: Re: TK Problem (me again)
by ichimunki (Priest) on Jan 05, 2001 at 20:20 UTC | |
Which is close to what you have as => and , are interchangeable (although the arrow is semantically easier to follow in this case). You may need to pass a reference to the filehandle instead of the filehandle, but I don't have a good handle on filehandles, so I'd recommend further inquiry after trying something more like the above. And most importantly your callback appears to be wrapped in an anonymous list reference, when all you really need is a sub reference. | [reply] [d/l] [select] |