Re: [pygtk] os.popen to gtk.TextView
I have make some experiments. And I have found a answer to my problem. :) child = pexpect.spawn('find /usr -type d') while gtk.events_pending(): gtk.main_iteration() line = child.readline() while line: while gtk.events_pending(): gtk.main_iteration() tbuffer1.insert_at_cursor(line) tview1.scroll_to_mark(tbmark1, 0.05, True, 0.0, 1.0) line = child.readline() regards Marcus This sort of thing seems reasonable, but I found in CANVAS that the more I did while gtk.events_pending() loops, the more problems I ran into. Threading is tough - you're going to want to do a callback based solution for this. -dave ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
Steve McClure schrieb: On Sun, 2005-04-03 at 18:11 +0200, Marcus Habermehl wrote: Steve McClure schrieb: >On Fri, 2005-03-25 at 09:40 +0100, Marcus Habermehl wrote: >> Steve McClure schrieb: >> >> >On Wed, 2005-03-23 at 15:27, Marcus Habermehl wrote: >> >> Hi. >> >> >> >> I want to write the output of os.popen('command') to a gtk.TextView. >> >> >> >> But I don't know how. :( >> >> >> >> If I use >> >> >> >> for line in os.popen('command').readlines(): >> >> textview.insert_at_cursor(line) >> >> >> >> I must wait untils 'command' has finished. >> >> >> >> Is there a better way? Is it not possible to wrote the output directly >> >> to a gtk.TextView? >> >> >> >> I have found some documentation about pipes or related things. But >> >> because my english isn't very good I doesn't understand it realy. >> >> >> >> Have anyone a hint for me? >> > >> >Try looking at os.popen3 >> > >> >You can do something like >> > >> [example] >> >> That isn't what I want. On your example I must wait until the command in >> os.popen3 has finished. >> >> If the command need some minutes the user doesn't know what the script >> doing. And I want that the user can see the output in "real-time". >> >> You know what I mean? > >Each time you read a line do: > while gtk.events_pending(): > gtk.main_iteration() > >to make sure the text widget is updated. Is that what you mean? > [...] How do you mean this? Befor os.popen or after os.popen? Normaly I use this: while gtk.events_pending(): gtk.main_iteration() for line in os.popen('do something').readlines(): tbuffer.insert_at_cursor(line) Here I must wait until 'do something' has finished. If I use the next example the command from os.popen will be executed two times. for line in os.popen('do something').readlines(): while gtk.events_pending(): gtk.main_iteration() tbuffer.insert_at_cursor(line) regards Marcus Try using readline() instead of readlines() on the pipe. I would create the pipe in a separate line of code. I have make some experiments. And I have found a answer to my problem. :) child = pexpect.spawn('find /usr -type d') while gtk.events_pending(): gtk.main_iteration() line = child.readline() while line: while gtk.events_pending(): gtk.main_iteration() tbuffer1.insert_at_cursor(line) tview1.scroll_to_mark(tbmark1, 0.05, True, 0.0, 1.0) line = child.readline() regards Marcus ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
On Fri, 2005-25-03 at 09:46 +0100, Marcus Habermehl wrote: > Fernando San MartÃn Woerner schrieb: > > >El miÃ, 23-03-2005 a las 21:27 +0100, Marcus Habermehl escribiÃ: > >> Hi. > >> > >> I want to write the output of os.popen('command') to a gtk.TextView. > > > >there's the example > > > >http://cvs.gnome.org/viewcvs/gnome-python/pygtk/examples/ide/gtkcons.py?view=markup > > > That could be what I'm searching for. But I think that I doesn't > understand the script realy. :( > > I think the class gtkoutfile in this script is interesting for me. But > there are so many token like __w, __b, __fn, a, etc. That makes me > perplexes. :( > > Sorry. > > Marcus > > def __init__(self, w, fn, font): self.__fn = fn self.__w = w self.__b = w.get_buffer() self.__ins = self.__b.get_mark('insert') self.__font = font you can simply rename them. def __init__(self, w, fn, font): self.passed_fn = fn self.use_this_window = w self.the_textbuffer = w.get_buffer() self.insert_mark = self.__b.get_mark('insert') self.__font = font If you want full terminal capability you can use the vte terminal widget. It is the library widget that gnome-terminal uses. It has a python interface, not as complete as the 'c' interface, but does work. It will give you a full speed fully working terminal in a pygtk app. http://developer.gnome.org/arch/gnome/widgets/vte.html -- Brian <[EMAIL PROTECTED]> ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
Fernando San Martín Woerner schrieb: El mié, 23-03-2005 a las 21:27 +0100, Marcus Habermehl escribió: Hi. I want to write the output of os.popen('command') to a gtk.TextView. there's the example http://cvs.gnome.org/viewcvs/gnome-python/pygtk/examples/ide/gtkcons.py?view=markup That could be what I'm searching for. But I think that I doesn't understand the script realy. :( I think the class gtkoutfile in this script is interesting for me. But there are so many token like __w, __b, __fn, a, etc. That makes me perplexes. :( Sorry. Marcus ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
Steve McClure schrieb: On Wed, 2005-03-23 at 15:27, Marcus Habermehl wrote: Hi. I want to write the output of os.popen('command') to a gtk.TextView. But I don't know how. :( If I use for line in os.popen('command').readlines(): textview.insert_at_cursor(line) I must wait untils 'command' has finished. Is there a better way? Is it not possible to wrote the output directly to a gtk.TextView? I have found some documentation about pipes or related things. But because my english isn't very good I doesn't understand it realy. Have anyone a hint for me? Try looking at os.popen3 You can do something like [example] That isn't what I want. On your example I must wait until the command in os.popen3 has finished. If the command need some minutes the user doesn't know what the script doing. And I want that the user can see the output in "real-time". You know what I mean? regards Marcus __ Gesendet von Yahoo! Mail - http://mail.yahoo.de Mit Yahoo! Suche finden Sie alles: http://suche.yahoo.de ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
Christian Reis schrieb: On Wed, Mar 23, 2005 at 06:16:15PM -0500, Steve McClure wrote: On Wed, 2005-03-23 at 15:27, Marcus Habermehl wrote: > I want to write the output of os.popen('command') to a gtk.TextView. Isn't this the topic of FAQ 14.23? http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq14.023.htp Yes, thats true. But if I use this I must wait until 'commend' has finished, too. And I want to insert the output without time lag. regards Marcus __ Gesendet von Yahoo! Mail - http://mail.yahoo.de Bis zu 100 MB Speicher bei http://premiummail.yahoo.de ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
On Wed, Mar 23, 2005 at 06:16:15PM -0500, Steve McClure wrote: > On Wed, 2005-03-23 at 15:27, Marcus Habermehl wrote: > > I want to write the output of os.popen('command') to a gtk.TextView. Isn't this the topic of FAQ 14.23? http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq14.023.htp Take care, -- Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331 ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] os.popen to gtk.TextView
On Wed, 2005-03-23 at 15:27, Marcus Habermehl wrote: > Hi. > > I want to write the output of os.popen('command') to a gtk.TextView. > > But I don't know how. :( > > If I use > > for line in os.popen('command').readlines(): > textview.insert_at_cursor(line) > > I must wait untils 'command' has finished. > > Is there a better way? Is it not possible to wrote the output directly > to a gtk.TextView? > > I have found some documentation about pipes or related things. But > because my english isn't very good I doesn't understand it realy. > > Have anyone a hint for me? Try looking at os.popen3 You can do something like stdin, stdout, stderr = os.popen3(command) while not done: try: outputstr = stdout.readline() if outputstr == '': done = 1 else: # do something with textview and outputstr except (IOError): # ignore interrupted system calls here otherwise done = 1 stdin.close() stdout.close() stderr.close() > > regards > Marcus > > ___ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ -- Steve McClure Racemi email: [EMAIL PROTECTED]75 5th St NE voice: 404-892-5850 Suite 333 fax: 404-892-7215 Atlanta, GA 30308 http://www.racemi.com ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] os.popen to gtk.TextView
Hi. I want to write the output of os.popen('command') to a gtk.TextView. But I don't know how. :( If I use for line in os.popen('command').readlines(): textview.insert_at_cursor(line) I must wait untils 'command' has finished. Is there a better way? Is it not possible to wrote the output directly to a gtk.TextView? I have found some documentation about pipes or related things. But because my english isn't very good I doesn't understand it realy. Have anyone a hint for me? regards Marcus ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/