X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Flogwindow.py;h=336818535b5a449769544a94190d7e9d27355116;hp=64d4e9fe0f6ff0b56eed112afec3c3e66e6afcad;hb=e3ff7b1a829714d72e135fd11f7746a01bc2492b;hpb=4c1046ce18cb25a8a045ca588d975723af36ea1a diff --git a/sface/logwindow.py b/sface/logwindow.py index 64d4e9f..3368185 100644 --- a/sface/logwindow.py +++ b/sface/logwindow.py @@ -1,3 +1,5 @@ +import sys + from PyQt4.QtCore import * from PyQt4.QtGui import * @@ -9,12 +11,30 @@ class LogWindow(QDialog): QWidget.__init__(self, parent) self.setWindowTitle("SFI Log") self.text = QTextBrowser(self) - + layout = QVBoxLayout() layout.addWidget(self.text) self.setLayout(layout) - def setText(self, txt): - self.text.setText(txt) + # To Baris: from the doc, + # QIODevice is abstract and can not be instantiated + # I am putting QObject just to let the GUI start. + #self.io = QIODevice(self) + self.io = QObject() + self.connect(self.io, SIGNAL('canReadLine()'), self.appendLine) + + def redirectOutput(self): + print "Redirecting all output to Log Window. Please open the log window to see the output" + self.old_stdout = sys.stdout + self.old_stderr = sys.stderr + sys.stdout = self.io + sys.stderr = self.io + + self.old_stdout.write("test") + self.text.append("io Test\n") + + def appendLine(self): + self.text.append(self.io.readLine()) +