Class: QgsProcessingParameterFile

class qgis.core.QgsProcessingParameterFile

Bases: QgsProcessingParameterDefinition, QgsFileFilterGenerator

An input file or folder parameter for processing algorithms.

QgsProcessingParameterFile(name: str, description: str = ‘’, behavior: Qgis.ProcessingFileParameterBehavior = Qgis.ProcessingFileParameterBehavior.File, extension: str = ‘’, defaultValue: Any = None, optional: bool = False, fileFilter: str = ‘’) Constructor for QgsProcessingParameterFile.

The extension argument allows for specifying a file extension associated with the parameter (e.g. “html”). Use fileFilter for a more flexible approach which allows for multiple file extensions. Only one of extension or fileFilter should be specified, if both are specified then fileFilter takes precedence.

QgsProcessingParameterFile(QgsProcessingParameterFile)

Enums

Behavior

alias of ProcessingFileParameterBehavior

Methods

asPythonString

param outputType:

asScriptCode

rtype:

str

behavior

Returns the parameter behavior (e.g. File or Folder).

checkValueIsAcceptable

param input:

clone

rtype:

QgsProcessingParameterDefinition

createFileFilter

rtype:

str

defaultGuiValueFromSetting

Default gui value for an algorithm parameter from settings

extension

Returns any specified file extension for the parameter.

fileFilter

Returns the file filter string for file destinations compatible with this parameter.

fromScriptCode

Creates a new parameter using the definition from a script code.

fromVariantMap

param map:

setBehavior

Sets the parameter behavior (e.g. File or Folder).

setExtension

Sets a file extension for the parameter.

setFileFilter

Sets the file filter string for file destinations compatible with this parameter.

toVariantMap

rtype:

Dict[str, Any]

type

rtype:

str

typeName

Returns the type name for the parameter class.

Behavior

alias of ProcessingFileParameterBehavior

asPythonString(self, outputType: QgsProcessing.PythonOutputType = QgsProcessing.PythonOutputType.PythonQgsProcessingAlgorithmSubclass) str
Parameters:

outputType (QgsProcessing.PythonOutputType = QgsProcessing.PythonOutputType.PythonQgsProcessingAlgorithmSubclass) –

Return type:

str

asScriptCode(self) str
Return type:

str

behavior(self) Qgis.ProcessingFileParameterBehavior

Returns the parameter behavior (e.g. File or Folder).

See also

setBehavior()

Return type:

Qgis.ProcessingFileParameterBehavior

checkValueIsAcceptable(self, input: Any, context: QgsProcessingContext = None) bool
Parameters:
Return type:

bool

clone(self) QgsProcessingParameterDefinition
Return type:

QgsProcessingParameterDefinition

createFileFilter(self) str
Return type:

str

defaultGuiValueFromSetting(self) Any

Default gui value for an algorithm parameter from settings

Returns:

default value from settings or invalid QVariant if there is no default value defined in the settings

New in version 3.34.

extension(self) str

Returns any specified file extension for the parameter.

Note

See fileFilter() for a more flexible approach.

See also

setExtension()

Return type:

str

fileFilter(self) str

Returns the file filter string for file destinations compatible with this parameter.

See also

setFileFilter()

See also

extension()

New in version 3.10.

Return type:

str

fromScriptCode(name: str, description: str, isOptional: bool, definition: str, behavior: Qgis.ProcessingFileParameterBehavior = Qgis.ProcessingFileParameterBehavior.File) QgsProcessingParameterFile

Creates a new parameter using the definition from a script code.

Parameters:
  • name (str) –

  • description (str) –

  • isOptional (bool) –

  • definition (str) –

  • behavior (Qgis.ProcessingFileParameterBehavior = Qgis.ProcessingFileParameterBehavior.File) –

Return type:

QgsProcessingParameterFile

fromVariantMap(self, map: Dict[str, Any]) bool
Parameters:

map (Dict[str) –

Return type:

bool

setBehavior(self, behavior: Qgis.ProcessingFileParameterBehavior)

Sets the parameter behavior (e.g. File or Folder).

See also

behavior()

Parameters:

behavior (Qgis.ProcessingFileParameterBehavior) –

setExtension(self, extension: str)

Sets a file extension for the parameter.

Calling this method resets any existing fileFilter().

Note

See setFileFilter() for a more flexible approach.

See also

extension()

Parameters:

extension (str) –

setFileFilter(self, filter: str)

Sets the file filter string for file destinations compatible with this parameter.

Calling this method resets any existing extension() setting.

See also

fileFilter()

See also

setExtension()

New in version 3.10.

Parameters:

filter (str) –

toVariantMap(self) Dict[str, Any]
Return type:

Dict[str, Any]

type(self) str
Return type:

str

typeName() str

Returns the type name for the parameter class.

Return type:

str