<?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 Add in reset combo box and selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-in-reset-combo-box-and-selection/m-p/592601#M46443</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created an add in with 2 combo boxes and I would like to add a reset button to my toolbar. So the toolbar will be the same as when I open Arc Map. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this code on stackexchange and i'm trying to adapt it but i'm still got errors. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;class ButtonReset(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for TestAddin_addin.reset (Button)"""


&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Déclaration du mxd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.mxd = arcpy.mapping.MapDocument('current')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer = arcpy.mapping.ListLayers(self.mxd, "",df)[0]


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Reinitialiser tous les couches de leur sélection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(layer,"CLEAR_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox1, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; combobox1.enabled = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox2, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; combobox2.enabled = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; def refresh(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I put the function below as proposed under the module declaration but not sure if it's the right place to put it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
import pythonaddins


def resetTool(toolID, defaultValue):
&amp;nbsp;&amp;nbsp;&amp;nbsp; toolID.value = defaultValue


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the error I get when trying to run my reset button :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;\TestAddin_addin.py", line 438, in onClick
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox1, "")
AttributeError: 'ButtonReset' object has no attribute 'resetTool'&lt;/PRE&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:26:42 GMT</pubDate>
    <dc:creator>Pierre-LucBoivin</dc:creator>
    <dc:date>2021-12-12T01:26:42Z</dc:date>
    <item>
      <title>Add in reset combo box and selection</title>
      <link>https://community.esri.com/t5/python-questions/add-in-reset-combo-box-and-selection/m-p/592601#M46443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created an add in with 2 combo boxes and I would like to add a reset button to my toolbar. So the toolbar will be the same as when I open Arc Map. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this code on stackexchange and i'm trying to adapt it but i'm still got errors. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;class ButtonReset(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for TestAddin_addin.reset (Button)"""


&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Déclaration du mxd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.mxd = arcpy.mapping.MapDocument('current')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer = arcpy.mapping.ListLayers(self.mxd, "",df)[0]


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Reinitialiser tous les couches de leur sélection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(layer,"CLEAR_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox1, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; combobox1.enabled = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox2, "")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; combobox2.enabled = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; def refresh(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I put the function below as proposed under the module declaration but not sure if it's the right place to put it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
import pythonaddins


def resetTool(toolID, defaultValue):
&amp;nbsp;&amp;nbsp;&amp;nbsp; toolID.value = defaultValue


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the error I get when trying to run my reset button :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;\TestAddin_addin.py", line 438, in onClick
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.resetTool(combobox1, "")
AttributeError: 'ButtonReset' object has no attribute 'resetTool'&lt;/PRE&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:26:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-in-reset-combo-box-and-selection/m-p/592601#M46443</guid>
      <dc:creator>Pierre-LucBoivin</dc:creator>
      <dc:date>2021-12-12T01:26:42Z</dc:date>
    </item>
  </channel>
</rss>

