What is a Python add-in?
An add-in is a customization, such as a collection of tools on a toolbar, that plugs into an ArcGIS for Desktop application (that is, ArcMap, ArcCatalog, ArcGlobe, and ArcScene) to provide supplemental functionality for accomplishing custom tasks.
ArcGIS 10 introduced a new and innovative Desktop add-in model, making it easier for you to customize and extend the ArcGIS for Desktop applications. The new add-in model provides you with a declarative-based framework for creating a collection of customizations conveniently packaged within a single, compressed file with a .esriaddin file extension.
In ArcGIS 10, add-ins are authored using .NET or Java along with Extensible Markup Language (XML). The XML describes the customizations, while the .NET or Java classes provide the custom behavior. The ArcObjects software development kit (SDK) includes an Add-Ins Wizard that integrates with development environments—such as Eclipse, Microsoft Visual Studio, and the free Express Editions of Visual Studio—to simplify development.
ArcGIS 10.1 introduces Python to the list of languages for authoring Desktop add-ins, providing you with an easy solution to extend desktop functionality. To simplify the development of Python add-ins, you must download and use the Python Add-In Wizard to declare the type of customization. The wizard will generate all the required files necessary for the add-in to work. Click here to download the Python Add-In Wizard.
A Python add-in is a single compressed file with a .esriaddin extension. It contains the following items:
- config.xml—An Extensible Markup Language (XML) file defining the static add-in properties (for example, author, version, caption, category, and so on).
- Python script—The Python script (.py file) containing your business logic.
- Resource files—Items, such as images, and in some cases, data that is used to support your add-in.
As a single, compressed file, add-ins are easy to share between users and plugged into a desktop application by copying the add-in file to a well-known folder and removed by deleting it from this folder.
For more information about sharing add-ins, see Sharing add-ins.
Knowing when to create a Python add-in
Before you decide to make an add-in, be sure it is the right development path for your project requirements.
If you want to add a collection of existing tools on a toolbar, or change the layout of menus or toolbars in an ArcGIS for Desktop application, you can configure the user interface (UI) to match your preferences. This does not require any programming or scripting. For more information, see About configuring the user interface. For more information about adding geoprocessing tools on a toolbar or menu, see Adding and removing tools on menus and toolbars.
If you need to run a set of geoprocessing tools to perform data analysis or data management, or produce a series of maps, consider creating a model with ModelBuilder or writing a Python script. For more information, see Geoprocessing with ModelBuilder, Geoprocessing with Python, and Automating map workflows.
If it is required to make a customization that performs an action in response to an event, or requires the use of the mouse to interact with the display, you should consider making an add-in. An example is a tool that requires the user to click and drag a rectangle over a map to define an area of interest. Another example is an application extension that saves the map document automatically anytime a layer is added or removed from the table of contents.
Getting started with Python add-ins
The following topics guide you through workflows that are available for Python users to create specific types of desktop add-ins: