diff --git a/python/plugins/processing/gui/FileSelectionPanel.py b/python/plugins/processing/gui/FileSelectionPanel.py index c67b2990cb5..2af83b7ab99 100644 --- a/python/plugins/processing/gui/FileSelectionPanel.py +++ b/python/plugins/processing/gui/FileSelectionPanel.py @@ -32,8 +32,9 @@ from processing.tools.system import * class FileSelectionPanel(QtGui.QWidget): - def __init__(self, isFolder): + def __init__(self, isFolder, ext = None): super(FileSelectionPanel, self).__init__(None) + self.ext = ext or '*' self.isFolder = isFolder self.horizontalLayout = QtGui.QHBoxLayout(self) self.horizontalLayout.setSpacing(2) @@ -70,7 +71,7 @@ class FileSelectionPanel(QtGui.QWidget): os.path.dirname(unicode(folder))) else: filenames = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', - path, '*.*') + path, '*.' + self.ext) if filenames: self.text.setText(u';'.join(filenames)) settings.setValue('/Processing/LastInputPath', diff --git a/python/plugins/processing/gui/ParametersPanel.py b/python/plugins/processing/gui/ParametersPanel.py index b138ae0b8b1..e5a9d7fdab9 100644 --- a/python/plugins/processing/gui/ParametersPanel.py +++ b/python/plugins/processing/gui/ParametersPanel.py @@ -277,7 +277,7 @@ class ParametersPanel(QtGui.QWidget): elif isinstance(param, ParameterRange): item = RangePanel(param) elif isinstance(param, ParameterFile): - item = FileSelectionPanel(param.isFolder) + item = FileSelectionPanel(param.isFolder, param.ext) elif isinstance(param, ParameterMultipleInput): if param.datatype == ParameterMultipleInput.TYPE_FILE: item = MultipleFileInputPanel() diff --git a/python/plugins/processing/parameters/ParameterFile.py b/python/plugins/processing/parameters/ParameterFile.py index 3244080ca4f..f6ef7c8294a 100644 --- a/python/plugins/processing/parameters/ParameterFile.py +++ b/python/plugins/processing/parameters/ParameterFile.py @@ -30,9 +30,10 @@ from processing.parameters.Parameter import Parameter class ParameterFile(Parameter): - def __init__(self, name='', description='', isFolder=False, optional=True): + def __init__(self, name='', description='', isFolder=False, optional=True, ext = None): Parameter.__init__(self, name, description) self.value = None + self.ext = ext self.isFolder = isFolder self.optional = optional @@ -51,6 +52,8 @@ class ParameterFile(Parameter): return False else: self.value = '' + if self.ext is not None and self.value != '': + return self.value.endswith(self.ext) return True def deserialize(self, s):