[PyKDE] QProcess: more guidance needed

David Boddie david at boddie.org.uk
Mon Mar 6 17:31:59 GMT 2006

On Mon, 06 Mar 2006, Tina Isaksen wrote:

> I need some QProcess pointers again I'm afraid.

No problem. It's a learning process for me, too!

> I need to know when the process awaits input on it's stdin.

This could be difficult.

> I've been experimenting with QProcess::Communication flags but I can't
> make sense of it's output. I've also looked for some sort of SIGNAL (which
> would be ideal) but no luck there either.

Yes, I hoped I would find a signal that tells you when more input
is required, but it looks like it's not quite as simple as that.

[Code snippet snipped]

The wroteToStdin() signal from QProcess is helpful when you're writing
to the other process's stdin stream, but it won't tell you when the
other process is waiting for input. If you were using streams directly
in Python, you might be able to tell whether the stdin stream is waiting,
but it doesn't look like it's possible with QProcess. :-(

Still, you need to know what the other process is asking for, so there
may be a way to tell by monitoring the output of the process. I imagine
that "apt-get upgrade" asks specific questions by writing to stdout and
reading back from stdin, so you might be able to look for these messages
in its output.

Of course, what you look for depends on the language in use - I notice that
your application is running a Norwegian language version of apt-get


so things could get interesting if you're looking for specific English
strings in the output. :-)

If you want, experiment a bit with this approach, and let us know how you
get on. Otherwise, the alternative approach might be to use Python's
process-handling support.

Good luck,


More information about the PyQt mailing list