本文整理匯總了Python中processing.core.SilentProgress.SilentProgress.setPercentage方法的典型用法代碼示例。如果您正苦於以下問題:Python SilentProgress.setPercentage方法的具體用法?Python SilentProgress.setPercentage怎麽用?Python SilentProgress.setPercentage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類processing.core.SilentProgress.SilentProgress
的用法示例。
在下文中一共展示了SilentProgress.setPercentage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handleAlgorithmResults
# 需要導入模塊: from processing.core.SilentProgress import SilentProgress [as 別名]
# 或者: from processing.core.SilentProgress.SilentProgress import setPercentage [as 別名]
def handleAlgorithmResults(alg, progress=None, showResults=True):
wrongLayers = []
htmlResults = False
if progress is None:
progress = SilentProgress()
progress.setText(QCoreApplication.translate('Postprocessing', 'Loading resulting layers'))
i = 0
for out in alg.outputs:
progress.setPercentage(100 * i / float(len(alg.outputs)))
if out.hidden or not out.open:
continue
if isinstance(out, (OutputRaster, OutputVector, OutputTable)):
try:
if hasattr(out, "layer") and out.layer is not None:
out.layer.setLayerName(out.description)
QgsMapLayerRegistry.instance().addMapLayers([out.layer])
else:
if ProcessingConfig.getSetting(
ProcessingConfig.USE_FILENAME_AS_LAYER_NAME):
name = os.path.basename(out.value)
else:
name = out.description
isRaster = True if isinstance(out, OutputRaster) else False
dataobjects.load(out.value, name, alg.crs,
RenderingStyles.getStyle(alg.commandLineName(), out.name),
isRaster)
except Exception:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
"Error loading result layer:\n" + traceback.format_exc())
wrongLayers.append(out.description)
elif isinstance(out, OutputHTML):
ProcessingResults.addResult(out.description, out.value)
htmlResults = True
i += 1
QApplication.restoreOverrideCursor()
if wrongLayers:
msg = "The following layers were not correctly generated.<ul>"
msg += "".join(["<li>%s</li>" % lay for lay in wrongLayers]) + "</ul>"
msg += "You can check the log messages to find more information about the execution of the algorithm"
progress.error(msg)
if showResults and htmlResults and not wrongLayers:
dlg = ResultsDialog()
dlg.exec_()
return len(wrongLayers) == 0