#初始化算法/工具的函数 def-initAlgorithm(self,config=None): self.add参数( Qgs处理参数枚举( “CHOICE_LAYER”,'标题',选项=['A','B'],默认值='A' ) )
def processAlgorithm(自我、参数、上下文、反馈): #从GUI中获取价值 choice=self.parameterAsString(参数,“choice_LAYER”,上下文) 打印(f“{choice}”)
#初始化算法/工具的函数 def-initAlgorithm(self,config=None): self.add参数( Qgs处理参数枚举( “CHOICE_LAYER”,'标题',选项=['A','B'],默认值='A' ) )
def processAlgorithm(自我、参数、上下文、反馈): #从GUI中获取价值 choice=self.parameterAsString(参数,“choice_LAYER”,上下文) 打印(f“{choice}”)
类示例处理算法(QgsProcessingAlgorithm): #等等。。。 def-initAlgorithm(self,config=None): self.add参数( Qgs处理参数枚举( “CHOICE_LAYER”,'标题',选项=['A','B'],默认值='A', usesStaticStrings=True#此处 ) ) def processAlgorithm(自我、参数、上下文、反馈): #从GUI中获取价值 choice=self.parameterAsString(参数,“choice_LAYER”,上下文) 打印(f“{choice}”) #等。。。。。
类示例处理算法(QgsProcessingAlgorithm): #等等。。。 def-initAlgorithm(self,config=None): 自我_ CHOICE_LAYER=[“A”,“B”]#实例属性 self.add参数( Qgs处理参数枚举( “CHOICE_LAYER”,'标题',选项=自身_ CHOICE_LAYER,defaultValue=self_ 选择层[0] ) ) def processAlgorithm(自我、参数、上下文、反馈): #从GUI中获取价值 choice=self.parameterAsInt(parameters,“choice_LAYER”,context)#<=====参数为int 打印(f“{choice}{self.choice_LAYER[choice]}”) #等。。。。。