I'm using ArcGIS 10.2.1 and have written an Python addin with multiple comboboxes and an "Unselect" button. The comboboxes run queries on the data and the button clears the selections.
I need the "Unselect" button to clear the comboboxes of their entries. I've tried both of these options:
1) Self.Editable=False, then the selection in the comboboxes disappear when the user selects something. That's what I posted this question in regards to.
2) Self.Editable=True, then the selection remains visible, but I can't get it to clear when the "Unselect" button is clicked, even when the selection is cleared. (Code below)
So, edit=true, can't get the unselect to clear the combobox, edit = false, the selection in the combobox automatically disappears.
Any other thoughts?
class ButtonUnselect(object):
"""Implementation for Walla_Walla_QueryTool_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
self.mxd = arcpy.mapping.MapDocument('current')
lyr = arcpy.mapping.ListLayers(self.mxd, "PODs")[0]
lyr2 = arcpy.mapping.ListLayers(self.mxd, "POUs")[0]
lyr3 = arcpy.mapping.ListLayers(self.mxd, "Management_Points")[0]
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
arcpy.SelectLayerByAttribute_management(lyr2, "CLEAR_SELECTION")
arcpy.SelectLayerByAttribute_management(lyr3, "CLEAR_SELECTION")
df = arcpy.mapping.ListDataFrames(self.mxd)[0]
df.extent = ext
ext = lyr2.getExtent()
combobox_2.__init__
class ComboBoxPurpose(object):
"""Implementation for Walla_Walla_QueryTool_addin.combobox_5 (ComboBox)"""
def __init__(self):
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWWWWWWWWWWWWWW'
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", "Purpose = '" + selection + "'")
arcpy.SelectLayerByAttribute_management(layer2, "NEW_SELECTION", "Purpose = '" + selection + "'")
arcpy.RefreshActiveView()
df = arcpy.mapping.ListDataFrames(self.mxd)[0]
layer1.getSelectedExtent()
layer2.getSelectedExtent()
df.zoomToSelectedFeatures()
def onEditChange(self, text):
pass
def onFocus(self, focused):
self.mxd = arcpy.mapping.MapDocument('current')
layer3 = arcpy.mapping.ListLayers(self.mxd, "PODs")[0]
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer3, ["Purpose"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
def onEnter(self):
pass
def refresh(self):
pass