Skip to content
Permalink
Browse files

[processing] force process events when algorithms report progress

Not the ideal way of doing it, but it will do the trick until we safely put algorithms in a different thread

Some cleaning of the main alg execution dialog
  • Loading branch information
volaya committed Jun 20, 2014
1 parent 9414717 commit 9256ca5b5cb898f171846725572a7bf5c838c7af
Showing with 7 additions and 18 deletions.
  1. +7 −18 python/plugins/processing/gui/AlgorithmExecutionDialog.py
@@ -76,9 +76,7 @@ def __init__(self, alg, mainWidget):
self.resize(650, 450)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
| QtGui.QDialogButtonBox.Close)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
self.runButton = QtGui.QPushButton()
self.runButton.setText('Run')
self.buttonBox.addButton(self.runButton,
@@ -128,8 +126,6 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.addWidget(self.buttonBox)
self.setLayout(self.verticalLayout)
self.buttonBox.rejected.connect(self.close)
self.buttonBox.button(
QtGui.QDialogButtonBox.Cancel).clicked.connect(self.cancel)

self.showDebug = ProcessingConfig.getSetting(
ProcessingConfig.SHOW_DEBUG_IN_DIALOG)
@@ -306,19 +302,6 @@ def error(self, msg):
self.resetGUI()
self.tabWidget.setCurrentIndex(1) # log tab

def iterate(self, i):
self.setInfo('<b>Algorithm %s iteration #%i completed</b>'
% (self.alg.name, i))

def cancel(self):
self.setInfo('<b>Algorithm %s canceled</b>' % self.alg.name)
try:
self.algEx.algExecuted.disconnect()
self.algEx.terminate()
except:
pass
self.resetGUI()

def resetGUI(self):
QApplication.restoreOverrideCursor()
self.progressLabel.setText('')
@@ -333,24 +316,30 @@ def setInfo(self, msg, error=False):
self.logText.append('<span style="color:red">' + msg + '</span>')
else:
self.logText.append(msg)
QCoreApplication.processEvents()

def setCommand(self, cmd):
if self.showDebug:
self.setInfo('<tt>' + cmd + '<tt>')
QCoreApplication.processEvents()

def setDebugInfo(self, msg):
if self.showDebug:
self.setInfo('<span style="color:blue">' + msg + '</span>')
QCoreApplication.processEvents()

def setConsoleInfo(self, msg):
if self.showDebug:
self.setCommand('<span style="color:darkgray">' + msg + '</span>')
QCoreApplication.processEvents()

def setPercentage(self, i):
if self.progress.maximum() == 0:
self.progress.setMaximum(100)
self.progress.setValue(i)
QCoreApplication.processEvents()

def setText(self, text):
self.progressLabel.setText(text)
self.setInfo(text, False)
QCoreApplication.processEvents()

0 comments on commit 9256ca5

Please sign in to comment.
You can’t perform that action at this time.