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])
Paul
11.7k1 gold badge31 silver badges48 bronze badges
asked Mar 30, 2016 at 20:41
4
  • 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? Commented Mar 30, 2016 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 !! Commented Mar 30, 2016 at 21:19
  • As a new user, be sure to take the Tour that introduces you to the site and its protocols. Commented Mar 30, 2016 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. Commented Mar 30, 2016 at 22:20

1 Answer 1

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.

answered Oct 31, 2016 at 23:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.