[pygtk] gobject.io_add_watch buffered?
Gabriele Lanaro
gabriele.lanaro at gmail.com
Wed May 6 21:26:15 WST 2009
Ok!! It's solved, the while cycle hide me that the writeout function was called only once..
So, the solution was that the writeout should return True, after a succesful reading, and False when it's finished.
(it's the last sentence in the reference guide..sorry for my distraction!!!)
--------------CodeLauncher.py correct------------------
def writeout(self,file,event):
print "triggered"
text=file.read(1)
iter = self.buffer.get_end_iter()
self.buffer.insert(iter,text)
if event==gobject.IO_HUP:
return False
else:
return True
------------------------------------------------------
Thank you very much :-)
On Wed, 06 May 2009 15:02:14 +0200
"A.T.Hofkamp" <a.t.hofkamp a tue.nl> wrote:
> Gabriele Lanaro wrote:
>
> > def writeout(self,file,event):
> > text=1
> > while text:
> > text=file.readline()
> > iter = self.buffer.get_end_iter()
> > self.buffer.insert(iter,text)
>
> I have not analysed your program, so I may be wrong, but here you seem to loop
> to read all output of file (a bad name for a handle btw).
>
> Instead of reading everything, read only what is available, and return.
> The io_watch should signal you the next time there is data.
>
> Albert
--
Gabriele Lanaro <gabriele.lanaro a gmail.com>
More information about the pygtk
mailing list