I was wondering if there is a way to add a button to a geoprocessing tool to validate and have a pop-up message before the user runs the tool.
For example, the Add Join tool has a button like this. I couldn't find a way to add a button though and am wondering if I am missing something. Thanks!
you can validate a tool
Customizing script tool behavior—ArcGIS Pro | Documentation
you can get a checkbox but not a button if have optional parameters
Here's a simple example tool that should work using @DanPatterson 's checkbox button idea. I use checkbox buttons this way all the time:
import arcpy
class ValidateButtonExample:
"""Generates frames for a given layout"""
def __init__(self) -> None:
self.category = "Example"
self.label = "Button Parameter"
self.description = "A Button Parameter Example"
return
def getParameterInfo(self):
validate_button = arcpy.Parameter(
name="validate_button",
displayName="Validate",
direction="Input",
datatype="GPBoolean",
parameterType="Required",
)
validate_button.value = False
return [validate_button]
def updateParameters(self, parameters:list[arcpy.Parameter], messages:list) -> None:
"""Modify the values and properties of parameters before internal validation is performed."""
params = named_params(parameters)
if params.validate_button.value:
self.validate(parameters, messages)
params.validate_button.value = False
return
def validate(self, parameters:list[arcpy.Parameter], messages:list) -> None:
"""This is run when someone clicks the validate checkbox"""
parameters = named_params(parameters)
# Implement your validation logic here
return
def execute(self, parameters:list[arcpy.Parameter], messages:list) -> None:
"""This is run when someone clicks the Run button"""
# Implement your tool logic here
return
def named_params(parameters:list[arcpy.Parameter]) -> object:
""" Return an object with named parameters """
params = object()
for param in parameters:
setattr(params, param.name, param)
return params
Thanks for that example, I might try to implement something like that.
One scenario I am concerned about is if a user starts checking and unchecking the box within seconds, which would probably interrupt any geoprocessing functions that need to happen in the validation and could confuse the tool.