Skip to content

Commit fb84920

Browse files
Andras Lassolassoan
authored andcommitted
Improve progress reporting
- Report percentage instead of fraction: "Running (0.6123123)" -> "Running (61.2%)" - Report completion time at the end: "Completed (12.3s)"
1 parent 8686bf5 commit fb84920

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

SimpleFilters/SimpleFilters.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections import OrderedDict
99
import re
1010
import threading
11+
import time
1112

1213
try:
1314
import queue
@@ -175,6 +176,8 @@ def setup(self):
175176
hlayout.addWidget(self.currentStatusLabel)
176177
self.layout.addLayout(hlayout)
177178

179+
self.filterStartTime = None
180+
178181
self.progress = qt.QProgressBar()
179182
self.progress.setRange(0,1000)
180183
self.progress.setValue(0)
@@ -319,14 +322,16 @@ def onCancelButton(self):
319322

320323

321324
def onLogicEventStart(self):
325+
self.filterStartTime = time.time()
322326
self.currentStatusLabel.text = "Running"
323327
self.cancelButton.setDisabled(False)
324328
self.progress.setValue(0)
325329
self.progress.show()
326330

327331

328332
def onLogicEventEnd(self):
329-
self.currentStatusLabel.text = "Completed"
333+
elapsedTimeSec = time.time() - self.filterStartTime
334+
self.currentStatusLabel.text = "Completed ({0:3.1f}s)".format(elapsedTimeSec)
330335
self.progress.setValue(1000)
331336

332337

@@ -336,7 +341,7 @@ def onLogicEventAbort(self):
336341

337342

338343
def onLogicEventProgress(self, progress):
339-
self.currentStatusLabel.text = "Running ({0:6.5f})".format(progress)
344+
self.currentStatusLabel.text = "Running ({0:3.1f}%)".format(progress*100.0)
340345
self.progress.setValue(progress*1000)
341346

342347

0 commit comments

Comments
 (0)