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"
Solved! Go to Solution.
import arcpy import pythonaddins class ButtonClass7(object): """Implementation for testNonEditCombo_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): combobox.value = '' combobox.refresh() class ComboBoxClass1(object): """Implementation for testNonEditCombo_addin.combobox (ComboBox)""" def __init__(self): self.editable = True self.enabled = True # introducing global global staticVal self.newfunction() self.value = staticVal = self.items[0] def onSelChange(self, selection): # redefining global global staticVal self.value = staticVal = selection print 'selection: {0}'.format(selection) def onEditChange(self, text): pass def onFocus(self, focused): if focused: self.newfunction() def onEnter(self): self.value = staticVal print 'self.refresh...so did the refresh function fire?' self.refresh() def refresh(self): arcpy.RefreshActiveView() print 'refreshed...' def newfunction(self): self.mxd = arcpy.mapping.MapDocument('current') self.items = [lyr.name for lyr in arcpy.mapping.ListLayers(self.mxd)]
import arcpy import pythonaddins class ComboBoxClass1(object): """Implementation for testNonEditCombo_addin.combobox (ComboBox)""" def __init__(self): self.editable = True self.enabled = True # introducing global global staticVal self.newfunction() self.value = staticVal = self.items[0] def onSelChange(self, selection): # redefining global global staticVal self.value = staticVal = selection print 'selection: {0}'.format(selection) def onEditChange(self, text): # I toyed with this function but decided not to use it in this example. pass def onFocus(self, focused): # if any layers are added/removed from the TOC, the list is refreshed. if focused: self.newfunction() def onEnter(self): self.value = staticVal print 'self.refresh...so did the refresh function fire?' self.refresh() def refresh(self): arcpy.RefreshActiveView() print 'refreshed...' def newfunction(self): self.mxd = arcpy.mapping.MapDocument('current') self.items = [lyr.name for lyr in arcpy.mapping.ListLayers(self.mxd)]
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] ext = lyr2.getExtent() df.extent = ext combobox_2.__init__ ComboBoxPriorityDateRange.__init__ combobox_5.__init__
import arcpy import pythonaddins class ButtonClass7(object): """Implementation for testNonEditCombo_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): combobox.value = '' combobox.refresh() class ComboBoxClass1(object): """Implementation for testNonEditCombo_addin.combobox (ComboBox)""" def __init__(self): self.editable = True self.enabled = True # introducing global global staticVal self.newfunction() self.value = staticVal = self.items[0] def onSelChange(self, selection): # redefining global global staticVal self.value = staticVal = selection print 'selection: {0}'.format(selection) def onEditChange(self, text): pass def onFocus(self, focused): if focused: self.newfunction() def onEnter(self): self.value = staticVal print 'self.refresh...so did the refresh function fire?' self.refresh() def refresh(self): arcpy.RefreshActiveView() print 'refreshed...' def newfunction(self): self.mxd = arcpy.mapping.MapDocument('current') self.items = [lyr.name for lyr in arcpy.mapping.ListLayers(self.mxd)]