Skip to content

Commit 5b2943a

Browse files
rhinoellaSpitz
andauthored
Display live output from running processes (#474)
* Live output of processes * Change 'setText' to append for smoother experience + remove unecessary code * Remove comment --------- Co-authored-by: Spitz <[email protected]>
1 parent 81a8ce8 commit 5b2943a

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

gudpy/gui/widgets/core/main_window.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,11 @@ def progressIncrementDCS(self, gudrunFile=None):
17791779
return 0
17801780
data = self.proc.readAllStandardOutput()
17811781
stdout = bytes(data).decode("utf8")
1782-
self.output += stdout
1782+
if stdout:
1783+
self.output += stdout
1784+
self.outputSlots.setOutputStream(
1785+
stdout
1786+
)
17831787
ERROR_KWDS = ["does not exist", "error", "Error"]
17841788
if [KWD for KWD in ERROR_KWDS if KWD in stdout]:
17851789
self.error = stdout
@@ -1843,7 +1847,11 @@ def progressIncrementPurge(self):
18431847
return 0
18441848
data = self.proc.readAllStandardOutput()
18451849
stdout = bytes(data).decode("utf8")
1846-
self.output += stdout
1850+
if stdout:
1851+
self.output += stdout
1852+
self.outputSlots.setOutputStream(
1853+
stdout
1854+
)
18471855
dataFiles = [self.gudrunFile.instrument.groupFileName]
18481856

18491857
def appendDfs(dfs):

gudpy/gui/widgets/core/output_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def data(self, index, role=Qt.DisplayRole):
181181
class OutputTreeView(QTreeView):
182182

183183
def __init__(self, parent):
184-
super(OutputTreeView, self).__init__(parent)
184+
super().__init__(parent)
185185

186186
def buildTree(self, gudrunFile, output, parent, keyMap=None):
187187
self.gudrunFile = gudrunFile

gudpy/gui/widgets/slots/output_slots.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ def __init__(self, widget, parent):
44
self.widget = widget
55
self.parent = parent
66

7+
def setOutputStream(self, stdout):
8+
self.widget.outputTextEdit.append(
9+
stdout
10+
)
11+
712
def setOutput(self, output, task, gudrunFile=None, keyMap=None):
813
if not gudrunFile:
914
gudrunFile = self.parent.gudrunFile
@@ -12,3 +17,7 @@ def setOutput(self, output, task, gudrunFile=None, keyMap=None):
1217
self.widget.outputTree.buildTree(
1318
gudrunFile, output, self, keyMap=keyMap
1419
)
20+
self.widget.outputTextEdit.verticalScrollBar().setValue(
21+
self.widget.outputTextEdit.verticalScrollBar(
22+
).maximum()
23+
)

0 commit comments

Comments
 (0)