Hi everyone,
I'm developing a custom Python Toolbox (.pyt) in ArcGIS Pro, and I'd like to include the default blue warning message that appears in many built-in geoprocessing tools. Specifically, the one that says: “This tool modifies the Input Table”, as shown in the snapshot below.
In ArcGIS Pro tools, this message appears just below the tool's name and above the input parameters. It's very useful to inform users that the tool will overwrite or modify the input data directly.
Is there any official way to enable or configure this message for custom Python tools?
Or is this behavior restricted to tools developed internally by Esri?
Thanks in advance!
Albert
It is part of esri's internal tool structure, however, you could "fake" it by adding a boolean parameter as the first parameter.
name : "proceed"
type : boolean
description : " This tool modifies the input file.. accept to proceed, bail otherwise"
The description is the hover description as described in
Set script tool parameters—ArcGIS Pro | Documentation
Obvious a True would allow one to proceed, False to quit... Perhaps make False the default requiring an overt True selection
Hi,
Thanks a lot for your suggestion and for taking the time to reply. Although it’s not exactly what I’m looking for, I really appreciate your message.
Best regards,
Albert
kind of a bodgy way to get what you want is have it so when validate or run is clicked have a tkinter message confirmation popup that tells the user what will happen
response = messagebox.askyesno("Confirm Action", "Are you sure you want to proceed?")
if response: # True if "Yes" was clicked
continue with toolbox if yes was clicked, return otherwise
To add to the moderately hacky workarounds, you can add a warning message to the top parameter.
import arcpy
class Toolbox:
def __init__(self):
self.label = "Warning Test"
self.alias = "WarningTest"
self.tools = [Tool]
class Tool:
def __init__(self) -> None:
self.description = "Test tool"
self.label = "Testing"
return
def getParameterInfo(self) -> list:
acknowledge = arcpy.Parameter(
displayName="Acknowledge",
name="acknowledge",
datatype="GPBoolean",
parameterType="Required",
direction="Input",
)
acknowledge.value = False
return [acknowledge]
def updateParameters(self, parameters: list[arcpy.Parameter]) -> None: ...
def updateMessages(self, parameters: list[arcpy.Parameter]) -> None:
if not parameters[0].value:
parameters[0].setWarningMessage('This Tool Modifies the Input Table, Please check this box to acknowledge')
else:
parameters[0].clearMessage()
def execute(self, parameters: list[arcpy.Parameter], messages: list) -> None:
if not parameters[0].value:
arcpy.AddWarning('Please check the acknowledge box to run this tool')
return
...
If you're authoring for Pro 3.4 or above you can check the new "Show banner that tool modifies the input data" option in the General properties. Looks official to me!
That's really cool, but I don't think it's been made available using the PYT interface yet. That's still pushing config to the ArcPro engine without Python using the toolbox DAML
Crud, I missed that in the title, good catch! I whipped up an Idea to get this into Python Toolbox tools, please click the picture of a thumb.