+import time
+
+class LogIO(QObject):
+ def __init__(self, parent, old_stdout):
+ QObject.__init__(self, parent)
+ self.io = StringIO()
+ self.old_stdout = old_stdout
+
+ def write(self, txt):
+ self.io.write(txt)
+ self.parent().update()
+
+ def getText(self):
+ val = self.io.getvalue()
+ # looks like there is no other way
+ # to empty the StringIO
+ del self.io
+ self.io = StringIO()
+ return val