Smita Tewari wrote:
> i'm absolutely clueless as to how to establish a link between the
> terminal and the pygtk window. i don't know how to get the output of
> a particular command run using os.system() on to the pygtk window so
> that it takes some user input and then proceeds. instead it gives
> the output on the terminal and takes user input and then proceeds,
> which is not what i want as this means coming out of the GUI.

You cannot not use os.system if you wish to communicate with the
spawned process: it does not redirect the standard input/output
streams. For just one-way communication, look at the module popen. For
both ways dialogues, the module subprocess (Python 2.4) will be more
suited. You may also try pexpect (http://pexpect.sourceforge.net)
which works with older versions of Python.

In all cases, take care when reading the output from the process: it
may be blocking and freeze the GUI. In order to read only when some
data is actually available, use the Python module select or, with
PyGTK, object.io_add_watch. Alternatively, with pexpect, there is a
timeout parameter.

Regards,
Franck
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to