in reply to Re: Realtime update of a textbuffer from STDOUT/STDERR in Gtk2
in thread Realtime update of a textbuffer from STDOUT/STDERR in Gtk2

Your code has too much in it, for me to run. I need to get Linux::CDROM, setup a bunch of directories, run as root, etc. If you want answers to questions, make the simplest possible script that demonstrates the problem. That way people can run it, and easily see the glitch. Usually when you do this simplification, you will answer your own question. This script just has too much clutter for me to make sense out of.

I think my problem is in the fact that everytime new data is in the filehandle, the buffer is overwritten. Is there a way to append data to the end of the buffer as it comes in?

Well, you are overwriting it with set_text. You can make a global variable, that you append to

my $buftext =''; ..... $buftext .= $sysbuffer; $buffer->set_text($buftext); # or better.....insert at the end_iter $buffer->insert( $buffer->get_end_iter, $sysbuffer );

The end_mark and end_iter concepts are hard to get right, it's best to make a few simple examples for yourself to play with them.

Also, if you read the warning messages, you should change 'add' to 'add_with_viewport' at the lines specified; it will make the scrollbars work better.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^3: Realtime update of a textbuffer from STDOUT/STDERR in Gtk2
by fang0654 (Initiate) on Aug 31, 2007 at 20:05 UTC
    Thank you, that change works like a charm. Your help is much appreciated!