+import sys
+
from PyQt4.QtCore import *
from PyQt4.QtGui import *
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)
+ self.io = QIODevice(self)
+ 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())
+
import os
+import sys
import time
from PyQt4.QtCore import *
self.connect(self.log, SIGNAL('linkActivated(QString)'),
self.showLogWindow)
+ def redirectOutputToLog(self):
+ self.logWindow.redirectOutput()
+
def showLogWindow(self, link):
self.logWindow.show()
+ self.logWindow.resize(500, 500)
self.logWindow.raise_()
self.logWindow.activateWindow()