<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to add a button in geoprocessing tool? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548514#M73018</link>
    <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, the Add Join tool has a button like this.&amp;nbsp; I couldn't find a way to add a button though and am wondering if I am missing something.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BittersDaniel_0-1728938040386.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/117200iF1A7ECA5BF524F6E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BittersDaniel_0-1728938040386.png" alt="BittersDaniel_0-1728938040386.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Oct 2024 20:36:42 GMT</pubDate>
    <dc:creator>BittersDaniel</dc:creator>
    <dc:date>2024-10-14T20:36:42Z</dc:date>
    <item>
      <title>How to add a button in geoprocessing tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548514#M73018</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, the Add Join tool has a button like this.&amp;nbsp; I couldn't find a way to add a button though and am wondering if I am missing something.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BittersDaniel_0-1728938040386.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/117200iF1A7ECA5BF524F6E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BittersDaniel_0-1728938040386.png" alt="BittersDaniel_0-1728938040386.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 20:36:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548514#M73018</guid>
      <dc:creator>BittersDaniel</dc:creator>
      <dc:date>2024-10-14T20:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a button in geoprocessing tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548522#M73019</link>
      <description>&lt;P&gt;you can validate a tool&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/customizing-script-tool-behavior.htm" target="_blank"&gt;Customizing script tool behavior—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you can get a checkbox but not a button if have optional parameters&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 21:13:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548522#M73019</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-10-14T21:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a button in geoprocessing tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548985#M73037</link>
      <description>&lt;P&gt;Here's a simple example tool that should work using &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt; 's checkbox button idea. I use checkbox buttons this way all the time:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

class ValidateButtonExample:
    """Generates frames for a given layout"""
    
    def __init__(self) -&amp;gt; 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) -&amp;gt; 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) -&amp;gt; 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) -&amp;gt; None:
        """This is run when someone clicks the Run button"""
        # Implement your tool logic here
        return


def named_params(parameters:list[arcpy.Parameter]) -&amp;gt; object:
    """ Return an object with named parameters """
    params = object()
    for param in parameters:
        setattr(params, param.name, param)
    return params&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 17:03:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1548985#M73037</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-10-16T17:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a button in geoprocessing tool?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1550898#M73073</link>
      <description>&lt;P&gt;Thanks for that example, I might try to implement something like that.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 14:40:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-add-a-button-in-geoprocessing-tool/m-p/1550898#M73073</guid>
      <dc:creator>BittersDaniel</dc:creator>
      <dc:date>2024-10-22T14:40:40Z</dc:date>
    </item>
  </channel>
</rss>

