[PyQt] stdin processing
Vladimir Pouzanov
farcaller at gmail.com
Tue Nov 6 15:08:49 GMT 2007
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?
More information about the PyQt
mailing list