Using ArcGIS 10.2.1 and Python 2.7
My python addin works in ArcMap if I open ArcMap with the Python window open, but if I open ArcMap without the Python window open - I get a "MISSING" tool error. See code below.
import arcpy
import pythonaddins
class IntersectionSearchCmb(object):
"""Implementation for IntersectionSearch_addin.combobox (ComboBox)"""
def __init__(self):
arcpy.AddMessage("HERE I AM 1")
print "Here i am 1"
cur,row = None, None
self.street_list = []
self.street_dict = {}
self.street_list.append("Battle St at 6th Ave")
self.street_list.append("6th Ave at Battle St")
self.street_dict["Battle St at 6th Ave"] = [688855.366,5616889]
self.street_dict["6th Ave at Battle St"] = [688855.366,5616889]
self.street_list.sort()
#self.street = list(set(self.street))
self.items = self.street_list
self.editable = True
self.enabled = True
self.width = 'WWWWWWWWWWW'
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWW'
def onSelChange(self, selection):
arcpy.AddMessage("HERE I AM 2")
print "Here i am 2"
self.mxd = arcpy.mapping.MapDocument('current')
self.df = arcpy.mapping.ListDataFrames(self.mxd)[0]
try:
x = self.street_dict[selection][0]
y = self.street_dict[selection][1]
extent = arcpy.Extent(x,y,x,y)
self.df.panToExtent(extent)
self.df.scale = 1500
arcpy.RefreshActiveView()
except:
pass
def onEditChange(self, text):
pass
def onFocus(self, focused):
arcpy.AddMessage("HERE I AM 3")
print "Here i am 3"
self.mxd = arcpy.mapping.MapDocument('current')
self.df = arcpy.mapping.ListDataFrames(self.mxd)[0]
pass
def onEnter(self):
pass
def refresh(self):
pass