[pygtk] Updating a TextBuffer line by line
John Finlay
finlay at moeraki.com
Fri Jan 23 08:37:48 WST 2009
Daniel Roesler wrote:
> 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?
>
You passed io_add_watch a class method as the callback - the first arg
of the classmethod must be self so prepend self to the method definition
params:
def read_output(self, source, condition):
John
More information about the pygtk
mailing list