2 from cStringIO import StringIO
4 from PyQt4.QtCore import *
5 from PyQt4.QtGui import *
7 from sface.config import config
10 def __init__(self, parent, old_stdout):
11 QObject.__init__(self, parent)
13 self.old_stdout = old_stdout
17 self.parent().update()
20 return self.io.getvalue()
22 class LogWindow(QDialog):
23 def __init__(self, parent=None):
24 QWidget.__init__(self, parent)
25 self.setWindowTitle("SFI Log")
26 self.text = QTextBrowser(self)
28 layout = QVBoxLayout()
29 layout.addWidget(self.text)
30 self.setLayout(layout)
32 self.logio = LogIO(self, sys.stdout)
34 def redirectOutput(self):
35 print "\n\nRedirecting all output to Log Window. Please open the log window to see the output\n"
36 self.old_stdout = sys.stdout
37 self.old_stderr = sys.stderr
38 sys.stdout = self.logio
39 sys.stderr = self.logio
42 self.text.setText(self.logio.getText())