[GIS] Recommendations about graphic interface for ArcPy/Python script

arcpyinterface

I have done some scripting using ArcPy and Python, and I want to make some interface to select some shapefile. What are the best graphic tools for Python to make this?

I don't need high detailed graphics.

Best Answer

ArcGIS-based solution (script tools + Python add-ins)

Having a Python script, you can make a custom script tool which will have the GUI any other core geoprocessing tool has. There are panels and boxes with Browse buttons, you can work with drop-down lists, check boxes, multi-value tables and many others. Read through all the parameter types you have (you can let users click on the map, draw features and use those features in the analysis and many other advanced features).

You can embed your script as a script tool in a geoprocessing toolbox and as a Python toolbox. Please refer to this help page Comparing custom and Python toolboxes and this GIS.SE Why learn/use Python Toolboxes over Python Script Tools? question to learn more when to use which. If you are just starting with the ArcGIS, consider testing script tools first before playing with Python toolboxes. Imo they are much easier to start working with.

As a last resort, if you want your end users will be able to have a custom dialog box when they will run your tools plus some additional parameter handling, consider embedding your Python script tool into a custom C++/.NET tool which might provide some additional GUI features, but you will be limited to the GP tools GUI scope anyway.

Keep in mind that you have Python add-ins which provide additional functionality with the windows, messages and dialogs. They are easy to build and distribute and since you are familar with Python and arcpy, you can start developing them in no time at all.

Desktop app / embed external GUI into a toolbox tool

If you want to develop a stand-alone application (such as .exe file for Windows), you would need to convert your script into a an .exe file with any utility such as py2exe. In order for this script to run, you would need to have ArcGIS installed on the machine because it will need to use arcpy site-package which is installed when installing ArcGIS.

As for the custom GUI, you have TKinter, PyQt/PySide, wxPython (some of the most used). There is a list of resources to learn from.

Because of the ArcGIS architecture, you might have troubles running custom GUI in the same process as ArcMap. I've seen some examples with Tkinter, but in general there are many issues to tackle with.

From what I've experienced I can say that it is probably better either to stay with the core GUI interface which provides in most of the time everything you'd ever need or develop a custom application importing arcpy (with some extra tuning in configuration) and working with the custom GUI (such as developed with PyQt) without starting any ArcGIS application at all.

There is an ArcGIS Idea Form Builder for Python Tools, but I seriously doubt Esri will develop this, so you better search for other alternatives.

I've done some tests embedding a custom Python script into a toolbox in ArcGIS Pro invoking the PyQt script and there were no problems setting up this and running. If using Pro is an option for you, you might consider this - it will be much easier to embed custom Python tools with own GUI into Pro than ArcMap. One of the gotchas is that Pro uses Python 3.4 and it is 64-bit Python which has certain implications for compatibility with PyQt or any other platform of your choice.

Related Question