[pygtk] Updating a TextBuffer line by line
Daniel Roesler
diafygi at gmail.com
Fri Jan 23 07:00:50 WST 2009
Ok, I tried that, but it's giving an error about the number of
arguments sent to read_output. "TypeError: display_details() takes
exactly 2 arguments (3 given)"
Here's my code:
--------------------------
gobject.io_add_watch(command.stdout, gobject.IO_IN | gobject.IO_HUP,
self.read_output)
....
def read_output(source, condition):
if condition == gobject.IO_IN:
line = source.readline()
self.txtbuffer.insert_at_cursor(line)
if condition == gobject.IO_HUP:
self.txtbuffer.insert_at_cursor("Command finished.")
return False
return True
--------------------------
Any ideas on why this is occurring?
Avast!
Daniel Roesler
diafygi at gmail.com
On Thu, Jan 22, 2009 at 2:45 PM, John Finlay <finlay at moeraki.com> wrote:
>
> Don't use command.poll() rather use gobject.io_add_watch to register a
> callback when data is available on the stdout pipe or the pipe is closed.
> Something like:
>
> gobject.io_add_watch(command.stdout, gobject.IO-IN | gobject.IO_HUP,
> read_output)
>
> def read_output(source, condition):
> if condition == gobject.IO_IN:
> line = source.readline()
> ....
> if condition == gobject.IO_HUP:
> ....
> return False
>
> return True
>
>
> John
>
>
More information about the pygtk
mailing list