Skip to content

Commit

Permalink
Minor cleanup ParametersPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 24, 2020
1 parent 6e2c21e commit 91d5191
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions python/plugins/processing/gui/ParametersPanel.py
Expand Up @@ -32,8 +32,6 @@

from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterExtent,
QgsProcessingParameterPoint,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterVectorDestination,
Expand All @@ -47,10 +45,11 @@
from qgis.utils import iface

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication, Qt
from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
QLabel, QCheckBox, QSizePolicy)
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import (
QLabel,
QCheckBox
)
from osgeo import gdal

from processing.gui.wrappers import WidgetWrapperFactory, WidgetWrapper
Expand All @@ -65,7 +64,6 @@


class ParametersPanel(BASE, WIDGET):

NOT_SELECTED = QCoreApplication.translate('ParametersPanel', '[Not selected]')

def __init__(self, parent, alg, in_place=False):
Expand Down Expand Up @@ -111,12 +109,6 @@ def layerRegistryChanged(self, layers):
except AttributeError:
pass

def formatParameterTooltip(self, parameter):
return '<p><b>{}</b></p><p>{}</p>'.format(
parameter.description(),
QCoreApplication.translate('ParametersPanel', 'Python identifier: ‘{}’').format('<i>{}</i>'.format(parameter.name()))
)

def initWidgets(self):
# If there are advanced parameters — show corresponding groupbox
for param in self.alg.parameterDefinitions():
Expand Down Expand Up @@ -183,8 +175,6 @@ def initWidgets(self):
desc = param.description()
if isinstance(param, QgsProcessingParameterExtent):
desc += self.tr(' (xmin, xmax, ymin, ymax)')
if isinstance(param, QgsProcessingParameterPoint):
desc += self.tr(' (x, y)')
if param.flags() & QgsProcessingParameterDefinition.FlagOptional:
desc += self.tr(' [optional]')
widget.setText(desc)
Expand All @@ -207,7 +197,8 @@ def initWidgets(self):

self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (QgsProcessingParameterRasterDestination, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
if isinstance(output, (QgsProcessingParameterRasterDestination, QgsProcessingParameterFeatureSink,
QgsProcessingParameterVectorDestination)):
check = QCheckBox()
check.setText(QCoreApplication.translate('ParametersPanel', 'Open output file after running algorithm'))

Expand All @@ -218,7 +209,7 @@ def skipOutputChanged(widget, checkbox, skipped):
# Do not try to open formats that are write-only.
value = widget.value()
if value and isinstance(value, QgsProcessingOutputLayerDefinition) and isinstance(output, (
QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
filename = value.sink.staticValue()
if filename not in ('memory:', ''):
path, ext = os.path.splitext(filename)
Expand Down

0 comments on commit 91d5191

Please sign in to comment.