good reference for Python Add-in

331
3
04-18-2019 02:53 PM
GeorgeRiner
New Contributor III

I have come across a task that appears to need a Python add-in.  Searching the internet for reference books, guides, training materials, for how to develop one of these things - I come up dry.  I've downloaded and 'installed' the "Python Add-in Wizard" and run 'addin_assistant.exe' to create the stub for the tool.  But obviously it appears to need a lot more work than just that. Any information on what I need to be doing in the dialog box for the addin_assistant ? What are the functions? how do they relate to the addin_assistant?

Are there really no thorough materials out there describing how this system works? How one goes from zero to a working python add-in??

A general outline of the tool is: user clicks on a point in the map, the tool searches an external database to find what information is available at that point, shows a list to the user, user selects one or more items, when are then loaded into the map as layers.

Apparently, the OnMapClick function/method is what I need here to get this working. But knowing that doesn't tell me how to use the python add-in development tools.

platform: ArcGIS 10.4 - 10.6 on Windows 10

(this comes with the ArcGIS install of Python 2.7.10)

Tags (2)
0 Kudos
3 Replies
JoeBorgione
MVP Esteemed Contributor

There's not much, but you can start here:  http://desktop.arcgis.com/en/arcmap/latest/analyze/python-addins/what-is-a-python-add-in.htm

I've used python addins in the past.  Take a look at the documentation link and if you need a little nudge I might be able to help you out.

That should just about do it....
0 Kudos
GeorgeRiner
New Contributor III

Thanks for the help, Joe. I've used the link you sent, plus some more searching. I've got a working python-addin that lets me capture a user clicking a point on the map. As someone in another forum remarked, it's relatively easy - within the scope of the OnMouseDownMap to write the x,y coordinates out to a file in place that within the user's profile.  I've got that working.

I gather that this general concept of an addin that allows the user to indicate a location on a map and then the addin finds additional resources to show to the user and then let the user select one or more of those additional resources to add to the map - is a rather common use-case for this python-addin tool/method.

However, other postings (over on stackexchange) are pretty clear that you cannot - within the execution scope of OnMouseDownMap - initiate a, say, Tkinter dialog with the user to present and select additional resources at that map location.

There is some reference to it being possible - somehow - to have the OnMouseDownMap then initiate some other kind of thread/process/tool that will allow a dialog box to be constructed so that the user can peruse and select.  But this is not yet clear to me how to accomplish. Something to do with GPToolDialog(), it seems. Probably in a "NONMODAL" form. But what I see, so far, is in the context of ArcGIS Desktop versions 10.2.2 and earlier.

Perhaps there have been more improvements to this interface in the 10.4.1 - 10.6.1 release levels?

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Python addins do have thier limitations.   I've read in several places that Tkinter doesn't work well within the ESRI realm.  Dialogue with the user is something I too explored without success.  I used Python addins at version 10.3 and 10.5.1 so I can't comment on the release with older versions. I'm not too familiar with gpdialog() other than it looks like the same as adding a script a script tool.

That should just about do it....
0 Kudos