[PyQt] Re: stdin processing
Vladimir Pouzanov
farcaller at gmail.com
Tue Nov 6 19:28:43 GMT 2007
Andreas Pakulat <apaku <at> gmx.de> writes:
> And what exactly is "self"? You should try to come up with a small
> self-contained example.
Just a QWidget:
class MainWin(QtGui.QTextEdit):
def __init__(self, mapper, parent=None):
QtGui.QTextEdit.__init__(self, parent)
self.qsn = QtCore.QSocketNotifier(0, QtCore.QSocketNotifier.Read, self)
self.connect(self.qsn, Qt.SIGNAL('activated(int)'), self.on_qsn)
self.stdin = QtCore.QFile(self)
self.stdin.open(0, QtCore.QIODevice.ReadOnly)
self.connect(self.stdin, Qt.SIGNAL('readyRead()'), self.on_stdinReadyRead)
def on_qsn(self, i):
self.on_stdinReadyRead()
def on_stdinReadyRead(self):
print "ready read!"
sys.stdout.flush()
line = self.stdin.readAll()
print "got [%s]" % line
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = MainWin(mapper)
win.show()
app.exec_()
More information about the PyQt
mailing list