Dropdown menus and Keyboard shortcuts generating python error messages

Discussion created by jayarem on Nov 5, 2013
Latest reply on Nov 5, 2013 by stacyrendall

I've got a very simple add-in that's just a drop-down menu that updates one attribute for the selected polygon. Whenever I open the keyboard shortcuts window, or, ever since I upgraded to 10.2, even click on the drop down menu containing the commands, I get an error of this type:

TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: 'assign_269' object is not callable

Here's a sample of the add-in:

import arcpy
import pythonaddins

mxd = arcpy.mapping.MapDocument("CURRENT")
layerList = arcpy.mapping.ListLayers(mxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
tableList = arcpy.mapping.ListTableViews(mxd)
for layer in layerList:
    if "Footprints_Edit" in layer.name:
        footprints_fc = layer
    if "Parcels_Edit" in layer.name:
        parcels_fc = layer
    if "Address" in layer.name:
        address_fc = layer
for table in tableList:
    if "Assessing" in table.name:
        assessing_table = table
    if "Condos" in table.name:
        condo_table = table

def rows_as_update_dicts(cursor):
    colnames = cursor.fields
    for row in cursor:
        row_object = dict(zip(colnames, row))
        yield row_object
        cursor.updateRow([row_object[colname] for colname in colnames])

class assign_101(object):
    """Implementation for btype_toolbar_addin.assign_civic_fraternal (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        fcount = int(arcpy.GetCount_management(footprints_fc).getOutput(0))
        if fcount <= 20:
            with arcpy.da.UpdateCursor(footprints_fc,["BTYPE"]) as brows:
                for row in rows_as_update_dicts(brows):
                    row['BTYPE'] = 101
            print "Too many footprints selected. Please select less than 20."


I have about 60 classes/buttons that all look like thatone, just the particular code is changed from 101 to some other number.