Now it's ok, with the flush() method the program give me the string every 2
seconds, but I have another problem:
I substitute the print text in the gobject.io_add_watch callback with a thing
like this:
----------------- -----------------------------------
class CodeLauncher
def __init__(self,executable,self.args):
# WIDGET DEFINITIONS, there is also the window etc..
tv=gtk.TextView()
self.buffer=tv.get_buffer()
def run(self):
p=subprocess.PIPE
cmdline=self.executable,self.args
child=subprocess.Popen(cmdline,stdout=p)
gobject.io_add_watch(child.stdout,gobject.IO_IN |
gobject.IO_HUP,self.writeout,priority=gobject.PRIORITY_HIGH)
gtk.main()
def writeout(self,file,event):
text=1
while text:
text=file.readline()
iter = self.buffer.get_end_iter()
self.buffer.insert(iter,text)
-------------------------------------------------------
Now the problem is that the output of the program is visualized only when the
program spawned (ex. blocking.py with flush)returns..and in the middle the
interface is blocked.
Maybe I've forgotten something...
--------
On Wed, 6 May 2009 07:22:01 +0200
Andi Albrecht <[email protected]> wrote:
> I think it's stdout that's buffered here. Have you tried to flush
> stdout after each print to actually write the output?
>
> import sys, time
> sys.stdout.write("foo 1")
> sys.stdout.flush()
> time.sleep(2)
> ...
>
> Andi
--
Gabriele Lanaro <[email protected]>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/