move domItem and domModel in xmlwindow
[sface.git] / sface / logwindow.py
index 64d4e9f..3368185 100644 (file)
@@ -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())
+