Select to view content in your preferred language

Addin Combo Box

2168
10
11-05-2013 08:44 AM
FredKellner1
Deactivated User
I have been struggling to get the combo box addin working properly on toolbars that I have created. So in attempt to better understand the combo box I have been trying to implement a combo box using the example from the documentation.

The documentation states "this topic examines the process of creating a combo box with the list of layers from the table of contents. Selecting a layer will create a fishnet covering the full extent of the layer".

And I have used the code example in the documentation

# Business logic to implement the ComboBox
def __init__(self):
        self.editable = True
        self.enabled = True

def onSelChange(self, selection):

 # When a new layer is selected, create a new fishnet using the extent of layer.
 layer = arcpy.mapping.ListLayers(self.mxd, selection)[0]
 desc = arcpy.Describe(layer.dataSource)
 extent = desc.Extent
 fishnet = arcpy.CreateFishnet_management(r'in_memory\fishnet',
                 '%f %f' %(extent.XMin, extent.YMin),
                 '%f %f' %(extent.XMin, extent.YMax),
                 0, 0, 10, 10,
                 '%f %f' %(extent.XMax, extent.YMax),
                 'NO_LABELS',
                 '%f %f %f %f' %(extent.XMin, extent.YMin, extent.XMax, extent.YMax), 'POLYGON')
 arcpy.RefreshActiveView()

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')
  layers = arcpy.mapping.ListLayers(self.mxd)
  self.items = []
  for layer in layers:
   self.items.append(layer.name)


But I have been unable to get the toolbar to work. The toolbar shows up in arcmap but there is no drop down and I get the missing message on the toolbar itself.

Any suggestions?

Thanks

Fred
Tags (2)
0 Kudos
10 Replies
JohnDye
Deactivated User
Can you post your addin file? I'll pull it down and see if I get the same thing on my end. Otherwise, I would think that you've likely got an old version sitting in your assembly cache and it's not being overwritten.

When you install a Python Addin, it extracts the files to the Assembly Cache and that is where ArcGIS reads all of your business logic and configuration file from as well as where it stores any data you ship with it. Sometimes, when you close ArcMap, it doesn't completely close and the executable will remain in process, even though it would appear that it is closed.

You can verify by looking at the Task Manager and ensuring there are no processes named ArcMap, AppRot, ArcGISConnection and ArcGISCacheMgr running. If you find any running, end them.

Also, I would suggest you go into your Assembly Cache and just empty it out.
On Windows7, the Assembly Cache is located at: C:\Users\<username>\AppData\Local\ESRI\Desktop10.0\AssemblyCache
On XP, you'll find it at: C:\Documents and Settings\<username>\Local Settings\Application Data\ESRI\Desktop10.0\AssemblyCache

Your addin will be contained in a folder in the above directories. The folder name for your addin is whatever your addin's AddinID was. Delete that Folder, then rebuild and reinstall the Addin and Start ArcMap.
0 Kudos