Skip to content
Permalink
Browse files

Basic logging widgets.

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@327 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Aug 1, 2012
1 parent a062d39 commit 4fab99354f6d1c8d08eda86db171c7ba03b7dfd5
Showing with 19 additions and 9 deletions.
  1. +19 −9 src/sextante/gui/AlgorithmExecutionDialog.py
@@ -67,6 +67,9 @@ def __init__(self, alg, mainWidget):
self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.scrollArea, "Parameters")
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
self.tabWidget.addTab(self.logText, "Log")
self.webView = QtWebKit.QWebView()
cssUrl = QtCore.QUrl(os.path.join(os.path.dirname(__file__), "help", "help.css"))
self.webView.settings().setUserStyleSheetUrl(cssUrl)
@@ -197,8 +200,7 @@ def accept(self):
self.algEx.textChanged.connect(self.setText)
self.algEx.iterated.connect(self.iterate)
self.algEx.start()
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s started" % self.alg.name)
self.log("Algorithm %s started" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
self.finish()
else:
@@ -230,8 +232,7 @@ def accept(self):
@pyqtSlot()
def finish(self):
self.executed = True
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s finished correctly" % self.alg.name)
self.log("Algorithm %s finished correctly" % self.alg.name)
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
@@ -248,8 +249,8 @@ def finish(self):
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
self.log(msg, True)
QMessageBox.critical(self, "Error", msg)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
self.close()
@@ -260,13 +261,11 @@ def error(self, msg):

@pyqtSlot(int)
def iterate(self, i):
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s iteration #%i completed" % (self.alg.name, i))
self.log("Algorithm %s iteration #%i completed" % (self.alg.name, i))

@pyqtSlot()
def cancel(self):
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s canceled" % self.alg.name)
self.log("Algorithm %s canceled" % self.alg.name)
try:
self.algEx.finished.disconnect()
self.algEx.terminate()
@@ -275,10 +274,21 @@ def cancel(self):
except:
pass

@pyqtSlot(str, bool)
def log(self, msg, error = False):
print "!", msg
if error:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
self.logText.append('<b>' + msg + '</b>')
else:
SextanteLog.addToLog(SextanteLog.LOG_INFO, msg)
self.logText.append(msg)

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

def setText(self, text):
self.progressLabel.setText(text)
self.log(text, false)

0 comments on commit 4fab993

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