I have a python add-in for Arc using the addin-assistant. It populates values in one combo box based on the selection from the other. All of that works fine.
What I can't figure out is how to keep the selected string from the first box visible. See the image... How do I get the "Zoom to:" combo box to display the value that the user selects?
I must be missing something but I cannot figure out what I am missing or where to put it. Code below.
import arcpy
import pythonaddins
class ComboBoxClass7(object):
"""Implementation for arcpythonAddins_addin.combobox_1 (ComboBox)"""
def __init__(self):
self.items = ["quad", "county"]
self.editable = False
self.enabled = True
self.dropdownWidth = 'WWWWWWWW'
self.width = 'WWWWWWWW'
def onSelChange(self, selection):
combobox.enabled = True
global fcName, fcField
if selection == "quad":
fcName = "quads"
fcField = "quad"
else:
fcName = "counties"
fcField = "COUNTYNM"
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
pass
class ComboBoxClass1(object):
"""Implementation for arcpythonAddins_addin.combobox (ComboBox)"""
def __init__(self):
self.editable = True
self.enabled = False
self.dropdownWidth = 'WWWWWWWWWWWW'
self.width = 'WWWWWWWWWWW'
def onSelChange(self, selection):
arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", fcField + "='" + selection + "'")
self.df = arcpy.mapping.ListDataFrames(self.mxd)[0]
self.df.zoomToSelectedFeatures()
arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION")
arcpy.RefreshActiveView()
def onEditChange(self, text):
pass
def onFocus(self, focused):
self.mxd = arcpy.mapping.MapDocument('current')
global layer
layer = arcpy.mapping.ListLayers(self.mxd, fcName)[0]
items = []
with arcpy.da.SearchCursor(layer, [fcField]) as cursor:
for row in cursor:
items.append(row[0])
self.items = sorted(items)
def onEnter(self):
pass
def refresh(self):
pass