Select to view content in your preferred language

How to add the default blue warning message in custom Python Toolboxes

104
7
yesterday
AlbertGallego
New Contributor

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.

snapshot_blue_warning.png

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

0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

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 


... sort of retired...
AlbertGallego
New Contributor

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

0 Kudos
GISDepartmentMFM
Regular Contributor

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

0 Kudos
HaydenWelch
MVP Regular Contributor

To add to the moderately hacky workarounds, you can add a warning message to the top parameter.

HaydenWelch_0-1751552081185.png 

HaydenWelch_1-1751552196585.png

 

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
        ...

 

0 Kudos
DavidSolari
MVP Regular Contributor

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!

DavidSolari_0-1751559314706.png

 

HaydenWelch
MVP Regular Contributor

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

DavidSolari
MVP Regular Contributor

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.