Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Multi-selection from Combo box in Python AddIn?

$
0
0

Is it possible to select more than one option from a combo box list in python Add ins for ArcGIS 10.x? Here is part of the code:

def onFocus(self, focused): 

    if focused:            
        self.mxd = arcpy.mapping.MapDocument('current')     
        layer = arcpy.mapping.ListLayers(self.mxd, "layer Name")[0]
        self.items = []       
        values = [row[0] for row in arcpy.da.SearchCursor(layer, ("Field Name"))]
        uniqueValues = set(values)

        for value in uniqueValues:
            self.items.append(value)  

def onSelChange(self, selection):

        try:    
            self.mxd = arcpy.mapping.MapDocument('current')  
            layer2 = arcpy.mapping.ListLayers(self.mxd, "Layer Name")[0]
            arcpy.SelectLayerByAttribute_management(layer2, "NEW_SELECTION", "Field Name = '" + selection + "'")             

            print "Processing. Please wait..."
            # Process: Calculate Field
            arcpy.CalculateField_management(layer2, "AUTH_STATUS", ""Authorized"", "PYTHON", "")
            arcpy.SelectLayerByAttribute_management(layer2, "CLEAR_SELECTION")

            print "Exporting to PDF. Please wait ..."
            arcpy.mapping.ExportToPDF(self.mxd, r"path to pdf output location" + "\"  + selection + ".pdf")    
            arcpy.RefreshActiveView()

        except:

            # By default any other errors will be caught here
            #
            e = sys.exc_info()[1]
            print(e.args[0])

Viewing all articles
Browse latest Browse all 767

Trending Articles