I'm using ArcGIS 10.2.1 and have written an Arcpy addin with multiple comboboxes. I need most of my comboboxes to be non-editable. However, when I set self.editable = false and a selection is made I cannot get this selection to stay visible in the combobox. A subset of my code is below:
Any thoughts would be appreciated!
Code:
class ComboBoxOwnerName(object):
"""Implementation for QueryTool_addin.combobox_2 (ComboBox)"""
def __init__(self):
self.editable = False
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWWWWWWWWWWWWWW'
self.mxd = arcpy.mapping.MapDocument('current')
layer4 = arcpy.mapping.ListLayers(self.mxd, "PODs")[0]
layer4_path= layer4.dataSource
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer4_path, ["Person"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
print "__init__"
def onSelChange(self, selection):
self.mxd = arcpy.mapping.MapDocument('current')
layer1 = arcpy.mapping.ListLayers(self.mxd, "PODs")[0]
layer2 = arcpy.mapping.ListLayers(self.mxd, "POUs")[0]
arcpy.SelectLayerByAttribute_management(layer1, "NEW_SELECTION", "Person = '" + selection + "'")
arcpy.SelectLayerByAttribute_management(layer2, "NEW_SELECTION", "Person = '" + selection + "'")
df = arcpy.mapping.ListDataFrames(self.mxd)[0]
layer1.getSelectedExtent()
layer2.getSelectedExtent()
df.zoomToSelectedFeatures()
global currentselection
currentselection = selection
print currentselection
print "Ran onSelChange"
self.items = [selection]
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
self.mxd = arcpy.mapping.MapDocument('current')
layer3 = arcpy.mapping.ListLayers(self.mxd, "PODs")[0]
self.items = [currentselection]
print "Ran refresh"