I believe that this is because the QFile object as implemented in the Qt
library on which PyQT builds does not emit the readyRead signal either. See:

http://doc.trolltech.com/4.3/qfile.html

As far as I can tell, there is no basic reason why a QFile should not emit a
readyRead signal. The analogous functionality exists for example in GLib. See
also this discussion:

http://lists.trolltech.com/qt-interest/2007-06/msg00614.html#msg00614

--Michiel.



Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032



-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Vladimir Pouzanov
Sent: Tue 11/6/2007 10:08 AM
To: [email protected]
Subject: [PyQt] stdin processing
 
Is there any way to read stdin line by line without blocking? My application
receives data over stdin (one command per line) and should react immediately.

I've tried to make such thing:
    self.stdin = QtCore.QFile(self)
    self.stdin.open(0, QtCore.QIODevice.ReadOnly)
    self.connect(self.stdin, Qt.SIGNAL('readyRead()'),
self.on_stdinReadyRead)
buy readyRead never fires.

Then I've added
    self.qsn = QtCore.QSocketNotifier(0, QtCore.QSocketNotifier.Read, self)
    self.connect(self.qsn, Qt.SIGNAL('activated(int)'), self.on_qsn)
and made on_qsn() call on_stdinReadyRead. It works but there's another
problem:
self.stdin.canReadLine() never returns true, and readAll() blocks forever.

any hint?

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to