[pygtk] Updating a TextBuffer line by line
diafygi at gmail.com
diafygi at gmail.com
Mon Jan 26 09:37:38 WST 2009
Thanks John! That did the trick. I'm just about finished with a gui
for ImapGrab.
Here's my final generic code:
--------------------------
gobject.io_add_watch(command.stdout, gobject.IO_IN | gobject.IO_HUP,
self.read_output)
....
def read_output(self, source, condition):
if condition == gobject.IO_IN:
line = source.readline()
self.txtbuffer.insert_at_cursor(line)
self.txtview.scroll_to_mark(self.txtbuffer.get_insert(), 0)
if condition == gobject.IO_HUP:
self.txtbuffer.insert_at_cursor("Command finished.")
return False
return True
--------------------------
Avast!
Daniel Roesler
diafygi at gmail.com
On 1/22/09, John Finlay <finlay at moeraki.com> wrote:
> 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