-2

I need to load all layer names into a combo box. I did the same using esri site. But the tool is showing [missing].

import arcpy import pythonaddins 

class LayersComboBoxClass(object):

    """Implementation for Tools_addin.combobox (ComboBox)""" 

    def __init__(self):
        self.editable = True
        self.enabled = True

    def onFocus(self, focused):
        # When the combo box has focus, update the combo box with the list of layer names. if focused:
        self.mxd = arcpy.mapping.MapDocument('current')
        # Edit position in code
        layers = arcpy.mapping.ListLayers(self.mxd)
        self.items = ["item1",item2]
  • 1
    Welcome to GIS.SE! Could you please post the code that is giving you trouble? It's difficult to give advice without knowing what doesn't work. – Paul Nov 5 '13 at 6:53
  • 1
    See this answer for some troubleshooting advice: gis.stackexchange.com/a/49845/753 – blah238 Nov 5 '13 at 7:35
  • I used resources.arcgis.com/en/help/main/10.2/index.html#/combo_box/… . But it is not working. What change I need to make. I got output as [Missing]. – Santhosh Samban Nov 5 '13 at 7:53
  • 1
    Going out on a limb, I am guessing you have misnamed something between the config file and the Python file. Either start over clean, or post your whole code project including XML config file somewhere, e.g. gist.github.com – blah238 Nov 5 '13 at 10:03
  • 1
    Please edit your code into your Question rather than the Comment box because the former has much better formatting options. – PolyGeo Nov 5 '13 at 11:17
0

In the ArcGIS 10.2 Online Help there is a Debugging Python add-ins page which says:

Anytime a tool or button fails to load and displays Missing on the toolbar instead of the expected icon or name, it is commonly due to a Python syntax error. Recheck your Python script for syntax errors or incorrect inputs to Python functions.

| improve this answer | |

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