What kind of UIs are available in Arcpy?

I've been writing some python scripts for colleagues that get stuff done, but I'm forced to have the users edit the scripts to insert the data paths and file names for their situation. The best user interface I can come up with is to put these user editable variables up in a section near the top of the script. I've been looking around for a way to make user interfaces more slick, like a VB browse to data box that would allow the user to browse their directories for their input files, but haven't found the correct place. I snooped around in the docs for Python Add-ins, but decided that is not what I'm looking for. http://video.esri.com/watch/2288/developing-python-add_dash_ins-for-arcgis-desktophttp:// at 3:08 pretty much tells me there is no custom UI support in python add-ins.

I think this is what I was looking for, except I'm using 10.2.2 so I found the corresponding help pages for my version. Reading the Docs now and went through the Add Script dialog. But I need to understand better the "Setting Script tool parameters" because I haven't figured out how I set a tool parameter to replace the input FCs that my python script now sets as variables from strings in the script e.g. InputFolder = "c:\\avdata\\PythonTest\\ClipLidar\\TestData\\Input"

Check the help files on GetParameterAsText (or sys.argv in pure python) In your script you will set your input parameters as such, then in the toolbox, you give it the type. For example, here are snippets from one of my scripts and how I establish the association between the inputs and how the tools parameters need to be identified.

Paul, do dig into parameter validation, this allows you quite a bit of capability to guide your user to get the right inputs in place -- BEFORE they click OK and run the tool. I have used this to make a script tool with more than 15 parameters amazingly easy to use. Of course this is all covered pretty well in the help both for toolboxes and python toolboxes.... However, if you want to check it out as a real-world example of what I'm talking about, see my presentation from the Esri UC, A flexible Python script tool for stratified random site selection.

If Python didn't run in some funky sandbox, you could use Tkinter. Last time I checked, if you clicked a button, the GUI died. C# has a System.Diagnostics.Process.Start() which could possibly be used in your GUI to execute your scripts and pass parameters. It works fine on the desktop but I have never tried it in ArcMap.

I have seen a very successful implementation of setting up a standalone .exe in an independent process which is launched synchronously from Python - using the subprocess module. This could be done with a TkInter Python script as well to "insulate" your arcmap session from the GUI data collection.

However, I agree with Dan Patterson that in most situations, working within the out of the box GUI tools provided with ArcGIS is best because users don't need to navigate a new UI - they can use the tool UI they are used to (either in ArcGIS Desktop, or soon, in Pro). Let Esri do the work on this one!

One other option that I didn't see mentioned is to turn your script into a ArcGIS Desktop Add-in. This is a little bit more advanced then creating a ArcToolbox script tool, but it does give you the ability to easily work with the ArcMap data frame/display. It really depends on what you are doing and what need to do with your script.

In Arc 10, you can add tools as buttons to the ArcMap / ArcCatalog UI. Addins are really most appropriate when you need the user to be able to interact with the map, layers, etc. Geoprocessing script tools are much more flexible as they can be used in Desktop and Pro, from Python (via arcpy) etc.

Yeah..I probably should have read the original post more closely, as Paul said that he read the documentation for creating a python add-in and decided against it.

I personally have created lots of ArcGIS Python Script tools, and a couple of add-ins. They both have advantages/disadvantages like everything else. One other thing that I just remembered (not sure if this still works) but you can/could drag a geoprocessing model into the ArcMap table of contents as a "Tool Layer". It would then allow you to run the model from the ArcMap table of contents. I used this a couple of times and it worked decent, still the python script tool is probably best if you don't need to access a users map click coordinates.

I thought the idea with script tools was that I could zip up a toolbox containing my script tool and sent it to a colleague. But when I try it, the toolbox unpacks at the destination and the tool source still references the python script in its old absolute path. What is the correct way to distribute script tools?

Thanks, I missed that somehow. That worked for me. I had started working on a python toolbox, but this is much easier. This also answers another question I had, How can my user get the script out of the toolbox to see how it works and maybe make slight changes.

The project was to export just an area of a LIDAR job by walking the directory tree of a LIDAR job, find tifs, shapefiles, and grids, clip them to an area of interest, and write them out with the same directory tree structure as the input folder, and make it run in 10.0 so without da.walk. There is some repeated code doing the clipping for each data type that might have been done in a function for extra style points, but each data type is a little different. Changed my script enough so two arguments are set by GetParametersAsText. I thought about setting env.overwriteOutput as an option in the dialog box, but then decided I always want to overwrite. Figured out how to add arcpy.AddMessage for some of the print statements I had to monitor progress.

I also figured out how to get Desktop Geoprocessing Options set so right click>edit goes to IDLE. I like this environment.