fix signals
[sface.git] / sface / logwindow.py
1 import sys
2
3 from PyQt4.QtCore import *
4 from PyQt4.QtGui import *
5
6 from sface.config import config
7
8
9 class LogWindow(QDialog):
10     def __init__(self, parent=None):
11         QWidget.__init__(self, parent)
12         self.setWindowTitle("SFI Log")
13         self.text = QTextBrowser(self)
14
15         layout = QVBoxLayout()
16         layout.addWidget(self.text)
17         self.setLayout(layout)
18
19         # To Baris: from the doc,
20         # QIODevice is abstract and can not be instantiated
21         # I am putting QObject just to let the GUI start.
22         #self.io = QIODevice(self)
23         self.io = QObject()
24         self.connect(self.io, SIGNAL('canReadLine()'), self.appendLine)
25
26     def redirectOutput(self):
27         print "Redirecting all output to Log Window. Please open the log window to see the output"
28         self.old_stdout = sys.stdout
29         self.old_stderr = sys.stderr
30         sys.stdout = self.io
31         sys.stderr = self.io
32
33         self.old_stdout.write("test")
34         self.text.append("io Test\n")
35
36     def appendLine(self):
37         self.text.append(self.io.readLine())
38         
39         
40