Class: QgsProcessingParameterFile

An input file or folder parameter for processing algorithms.

Class Hierarchy

Inheritance diagram of qgis.core.QgsProcessingParameterFile

Base classes

QgsProcessingParameterDefinition

Base class for the definition of processing parameters.

QgsFileFilterGenerator

Abstract interface for classes which generate a file filter string.

Enums

Behavior

alias of ProcessingFileParameterBehavior

Methods

behavior

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

extension

Returns any specified file extension for the parameter.

fileFilter

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

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.

Static Methods

fromScriptCode

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

typeName

Returns the type name for the parameter class.

class qgis.core.QgsProcessingParameterFile[source]

Bases: QgsProcessingParameterDefinition, QgsFileFilterGenerator

__init__(name: str | None, description: str | None = '', behavior: Qgis.ProcessingFileParameterBehavior = Qgis.ProcessingFileParameterBehavior.File, extension: str | None = '', defaultValue: Any = None, optional: bool = False, fileFilter: str | None = '')

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.

Parameters:
  • name (Optional[str])

  • description (Optional[str] = '')

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

  • extension (Optional[str] = '')

  • defaultValue (Any = None)

  • optional (bool = False)

  • fileFilter (Optional[str] = '')

__init__(a0: QgsProcessingParameterFile)
Parameters:

a0 (QgsProcessingParameterFile)

Behavior

alias of ProcessingFileParameterBehavior

behavior(self) Qgis.ProcessingFileParameterBehavior[source]

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

See also

setBehavior()

Return type:

Qgis.ProcessingFileParameterBehavior

extension(self) str[source]

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[source]

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

See also

setFileFilter()

See also

extension()

Added in version 3.10.

Return type:

str

static fromScriptCode(name: str | None, description: str | None, isOptional: bool, definition: str | None, behavior: Qgis.ProcessingFileParameterBehavior = Qgis.ProcessingFileParameterBehavior.File) QgsProcessingParameterFile | None[source]

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

Parameters:
  • name (Optional[str])

  • description (Optional[str])

  • isOptional (bool)

  • definition (Optional[str])

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

Return type:

Optional[QgsProcessingParameterFile]

setBehavior(self, behavior: Qgis.ProcessingFileParameterBehavior)[source]

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

See also

behavior()

Parameters:

behavior (Qgis.ProcessingFileParameterBehavior)

setExtension(self, extension: str | None)[source]

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 (Optional[str])

setFileFilter(self, filter: str | None)[source]

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()

Added in version 3.10.

Parameters:

filter (Optional[str])

static typeName() str[source]

Returns the type name for the parameter class.

Return type:

str