Add in reset combo box and selection

2754
0
05-12-2015 08:01 AM
Pierre-LucBoivin
Occasional Contributor

Hi,

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
        arcpy.SelectLayerByAttribute_management(layer,"CLEAR_SELECTION")
        self.resetTool(combobox1, "")
        combobox1.enabled = False
        self.resetTool(combobox2, "")
        combobox2.enabled = False
        arcpy.RefreshActiveView()
    def refresh(self):
        pass




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 :

\TestAddin_addin.py", line 438, in onClick
    self.resetTool(combobox1, "")
AttributeError: 'ButtonReset' object has no attribute 'resetTool'

Thanks for your help

0 Kudos
0 Replies