Dropdown menus and Keyboard shortcuts generating python error messages

320
1
11-05-2013 09:33 AM
JamesMcBroom1
New Contributor
Hello,

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
        else:
            print "Too many footprints selected. Please select less than 20."
        arcpy.RefreshActiveView()

....


I have about 60 classes/buttons that all look like thatone, just the particular code is changed from 101 to some other number.
Tags (2)
0 Kudos
1 Reply
StacyRendall1
Occasional Contributor III
Hello,

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


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


Reading the traceback it appears you are trying to access (call) assign_269, but this has not been created. You need to go through your code and check it has been created the same way as the other classes.
0 Kudos