Download presentation
Presentation is loading. Please wait.
Published byNorah Taylor Modified over 8 years ago
1
CREATING ARCGIS DESKTOP ADD-INS USING PYTHON AND RELATED PACKAGES/MODULES 2016 AGIC Education and Training Symposium September 22, 2016 Erik Glenn ● Pima County ITD-GIS
2
Presentation Outline Overview 20 minutes + 5 mins for questions Types of add-ins Creating add-ins Testing, sharing, and extending add-ins Simple example Additional resources Summary/Questions
3
What are Add-ins? Desktop application customization User interface All Desktop products (ArcMap, ArcCatalog, ArcGlobe, ArcScene) Introduced at Desktop version 10.0 Very simple to distribute, install and use
4
When Should You Use Add-ins? Limitations of toolboxes (custom & Python) Increasing complexity: Toolboxes => Desktop add-ins => Extending add-ins What are you trying to accomplish? Geoprocessing (ONLY FOR TRIGGERING…) Rearranging existing tools or putting them in custom toolbar (NO) Interacting with user interface (YES!) Running code based on response to a Desktop event (YES!)
5
Benefits of Add-ins Easy to build, install and share Don’t need to build installation programs Don’t require COM registration Can build with three different development environments: .NET Java Python, too!
6
Python Add-ins vs..NET/Java Python Add-ins introduced at version 10.1 Even easier! No DLLs Can use ArcPy rather than ArcObjects Fewer lines of code Less development time
7
Limitations of Python Add-ins Can’t use in ArcGIS Pro Have to import a toolbox to Pro, or use ArcGIS Pro SDK for.NET Not backward-compatible Can’t use full functionality of ArcObjects No officially-supported module for custom user interface components Tool license level requirements still apply
8
Types of Python Add-ins Toolbars are now dockable! Python and.NET tools can reside on the same toolbar! Buttons can also be generated through Customize Mode
9
Add-in Manager, Extensions, and Toolbars
10
Creating Python Add-ins Python Add-in Wizard Downloadable from Esri Extract files Use addin_assistant.exe located in bin folder All related files needed to create add-ins are included Creates project folder with three main components: config.xml Install folder (contains Python script with business logic) Images folder Next, use makeaddin.py to create archive The resulting *.esriaddin file can be used to install the add-in
11
Creating Python Add-ins (Cont’d) Can add additional folders and files Benefits of.esriaddin method .esriaddin file is really just a compressed file Well-known folders
12
Config.xml Describes the add-in and its customizations Created by Add-in Wizard Shouldn’t need to be edited
13
Images Folder Contains all graphics associated with the add-in Images that show up for tools, Add-In Manager, etc. Graphics copied into this folder automatically by Add-In Wizard
14
Holds the Python script for the add-in The script defines the behavior of the customizations described in config.xml Classes created by Add-In Wizard All pertinent functions for each class also created Only need to keep those you will use Additional folders and files can also be placed in this folder e.g. toolboxes, tools, data These will be compressed and included when the add-in is created Install Folder
15
Pythonaddins Module Separate Python module Like arcpy Includes functions for supporting Python add-ins Can only be used within a Python add-in, not in scripts or script tools Functions like OpenDialog(), MessageBox(), GetSelectedTOCLayerorDataFrame(), ProgressDialog()
16
Final Steps Edit the Python script as needed Don’t rename classes as class names are created by / referenced in config.xml Update functions Delete all functions not implemented For clarity To ensure they’re never called by the application Re-save the script Create add-in by running makeaddin.py Install the add-in by double-clicking the *.esriaddin file
17
Testing/Debugging/Editing Take advantage of your Python IDE Use Print statements and review Exception Errors Use Add-In Wizard to made edits to existing add-ins (can also edit config.xml directly)
18
Sharing Add-ins One small file makes it easy to share Place in well-known location to install; remove to uninstall Add-in can be updated with new version by merely overwriting the old file Add-ins can be digitally signed for security Linked to standard ITU X.509 digital certificate Use ESRISignAddIn.exe utility that comes with Python Add-in Wizard Administrative setting in Desktop to control security for all add-ins
19
Sharing Add-ins (Cont’d) Email attachment Placing in shared directory that’s added to list of well-known folder locations ArcGIS Online
20
Extending Python Add-ins Additional functionality, graphics, interfaces Thousands of 3 rd -party libraries => Python Package Index Is a GIS category (browse under “Scientific/Engineering”) Examples: wxPython Plotly ReportLab R, Pandas, SciPy, GDAL, Numpy, Shapely, Pysal…
21
wxPython A GUI toolkit for Python Is Python extension module that wraps around wxWidgets library (C++) Can use wxGlade, a GUI designer that creates wxPython code Eric Pimpler (GeoSpatial Training Services) has created a great Add-in using wxPython
22
ReportLab A PDF toolkit for Python Can be used to create data-driven PDF documents and custom vector graphics Three layers: A graphics canvas API that renders PDF pages A charts and widgets library for creating data graphics A page layout engine that builds documents from elements
23
Simple Example: StreetView Add-In
24
Acknowledgements / Additional Resources Ian Broad, Thinking Spatially (blog @ ianbroad.com) GeoSpatial Training Services Several Python training courses Eric Pimpler’s books: Programming ArcGIS with Python Cookbook ArcGIS Blueprints ArcGIS Desktop help docs Downloadable ArcGIS Desktop Python Add-ins on ArcGIS Online (search for tools and ArcGIS Desktop Content)
25
Acknowledgements / Additional Resources Python add-in class properties and functions: desktop.arcgis.com/en/arcmap/latest/analyze/python- addins/button-class.htm, …/combobox-class.htm, …/tool-class.htm, …/extension.class.htm wxpython.org blog.pythonlibrary.org/category/wxpython reportlab.com/opensource plot.ly pypi.python.org packaging.python.org
26
Summary Python add-ins are a great way to customize the user interface for any of the ArcGIS Desktop products Yes, there are limitations… Regardless, they’re fairly easy to create, edit, distribute and use Until Desktop is deprecated (?) and Pro takes over, they will continue to be forward-compatible with future versions
27
Questions? Erik Glenn Senior GIS Analyst Pima County ITD-GIS 33 N Stone Ave, 15 th Floor Tucson, AZ 85701-1439 erik.glenn@pima.gov (520) 724-6604 Erik Glenn Senior GIS Analyst Pima County ITD-GIS 33 N Stone Ave, 15 th Floor Tucson, AZ 85701-1439 erik.glenn@pima.gov (520) 724-6604
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.