1

I am running ArcGIS 10.2.2 Version 10.2.2.3552, using ArcMap.

I've watched the tutorial here (http://training.esri.com/Courses/ts_PythonAdd-Ins/player.cfm?) and I'm still not understanding this. I am still in the beginner phase of understanding and using python. I have created a script that when ran outside of arcmap everything works great. Its complicated though to have people install pyscripter and then load my code. My understanding is that i can create a button in arcmap that will run the code for them? Is there a limit on what can be accomplished with this button?

When i post my script underneath and install via the add-in manager:

import arcpy
import pythonaddins

class ButtonClass4(object):
    """Implementation for Export Button_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):

I get a nice little missing icon with a circle and line going through it. What am i missing here?

  • 1
    Yes, there is a limit, python can only go just below the surface of ArcGis; if you want to go deeper you will need C# or VB.net and ArcObjects. Based on what you're saying it sounds like the problem could be in the xml (esriaddin) that goes with the tool or that the addin path isn't found - confirm that the addin is actually added in ArcMap with the addin manager and ensure the icon can be located. – Michael Stimson Mar 9 '15 at 21:59
4

Personally, I think Python Add-ins are a little complicated for someone who is "still in the beginner phase of understanding and using python".

If you are now comfortable writing some Python code in an IDE like PyScripter (I usually just use IDLE), then I think your next logical step is to turn your code into Python script tools in standard toolboxes.

These are very easy to add to your menus as buttons by using:

  1. Customize | Customize Mode
  2. Commands tab
  3. Click [ Geoprocessing Tools ] at the bottom
  4. Click Add Tools to browse to your toolbox and tool
  5. Now that your tool appears in Commands you can drag and drop it onto any of your toolbars
  6. Close the Customize dialog to test your tool

Python Add-ins, and also Python toolboxes, are very powerful and well worth learning to use a little later but I think you will find mastering Python script tools makes a great intermediary step.

  • Very helpful! I got everything set up but one of the problems i ran into inside of arcmap for my script was my raw_input failing, EOF line. Is there a way to implement raw_input into the toolbox? – Joey Carl Mar 10 '15 at 13:29
  • Got it working! I used sys.argv instead of raw_input :) Thanks everyone! – Joey Carl Mar 10 '15 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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