[pygtk] Using python vte

Michael Hohn mhhohn at lbl.gov
Thu Sep 6 01:47:28 WST 2007


Edward A Robinson wrote:
> Him Im trying to use python vte to create a terminal and issue it
> commands in real time
>
> I have tried to use this code
>
> #!/usr/bin/env python
>
> import os
> import gtk
> import vte
> import time
> from subprocess import Popen, PIPE
>
> def show_callback(terminal):
>     terminal.feed_child('cd /\n')
>     terminal.feed_child('whoami\n')
>     terminal.feed_child('echo test\n')
>     for ii in range (10):
>         terminal.feed_child('echo ' + str(ii + 1)  + '\n')
>         time.sleep(1)
>
> def write(terminal, text):
>     x, y = terminal.get_cursor_position()
>     terminal.feed(text + '\n', len(text) + 1)
>
> window = gtk.Window()
> window.connect('destroy', lambda w: gtk.main_quit())
>
> terminal = vte.Terminal()
> terminal.connect("show", show_callback)
>
> child_pid = terminal.fork_command()
>
> #write(terminal, '1234567890')
>
> window.add(terminal)
> window.show_all()
> gtk.main()
>
> But instead of printing it out in real time it waits 10 seconds then
> prints it, any feedback would be great. Thanks.
>
>   
It looks like show_callback is called by the event handler, but runs for 
10 seconds without letting other display events process.  You could try 
adding one command at a time via gtk.timeout_add() instead.

-- Mike


More information about the pygtk mailing list