1

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])
  • Are you able to include a picture of what you are looking for and also a code snippet that illustrates what you have tried, please? – PolyGeo Mar 30 '16 at 20:47
  • what I'm trying to do is that the the combo box will be populated from field values of a layer, then the user select from the list to generate pdf map. It is working for selecting one value at a time, but I'm wondering if there is a way to select more than one before the next piece of code is executed. I have included part of the code. Thanks !! – Dan Mar 30 '16 at 21:19
  • As a new user, be sure to take the Tour that introduces you to the site and its protocols. – PolyGeo Mar 30 '16 at 21:26
  • 1
    At the moment the code you are presenting looks like two functions just copy/pasted from your Python script. For a code snippet I recommend starting a test addin and just include the bits that illustrate what you are asking about. That way you'll be able to include working code that potential answerers will be able to test. – PolyGeo Mar 30 '16 at 22:20
1

My understanding is that combo boxes in python addins behave the same as they do in the rest of ArcGIS. That is, you cannot select multiple values in a single combo box. For example, the scale drop down is a combo box. You cannot select multiple scales. Similarly, you cannot select multiple values from the "zoom to percent" combo box in the Layout. Hope that clarifies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.