AnsweredAssumed Answered

Add in reset combo box and selection

Question asked by Pi-Hellz on May 12, 2015



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.


I found this code on stackexchange and i'm trying to adapt it but i'm still got errors.


class ButtonReset(object):
    """Implementation for TestAddin_addin.reset (Button)"""

    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #Déclaration du mxd
        self.mxd = arcpy.mapping.MapDocument('current')
        layer = arcpy.mapping.ListLayers(self.mxd, "",df)[0]

        #Reinitialiser tous les couches de leur sélection
        self.resetTool(combobox1, "")
        combobox1.enabled = False
        self.resetTool(combobox2, "")
        combobox2.enabled = False
    def refresh(self):


Also I put the function below as proposed under the module declaration but not sure if it's the right place to put it.


import arcpy
from arcpy import env
import pythonaddins

def resetTool(toolID, defaultValue):
    toolID.value = defaultValue


Here the error I get when trying to run my reset button :


\", line 438, in onClick

    self.resetTool(combobox1, "")

AttributeError: 'ButtonReset' object has no attribute 'resetTool'

Thanks for your help