[PyQt] stdin processing
Michiel De Hoon
mdehoon at c2b2.columbia.edu
Wed Nov 7 00:46:37 GMT 2007
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: pyqt-bounces at riverbankcomputing.com on behalf of Vladimir Pouzanov
Sent: Tue 11/6/2007 10:08 AM
To: pyqt at riverbankcomputing.com
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 PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list