Bring back the old File Save Window in Python Toolboxes

76
0
06-30-2020 07:07 AM
Status: Open
Labels (1)
New Contributor III

In ArcGIS Pro 2.4 a Python Toolbox with file output would show a default Windows Save Window.

        outjson = arcpy.Parameter(
displayName="Output JSON",
name="out_json",
datatype="DEFile",
parameterType="Required",
direction="Output")‍‍‍‍‍‍

When opening the Tool in ArcGIS Pro it would look like this:

Clicking the Browse window shows a default Windows File Save Window

My users would enter a new file name in the File Name text box, or they click an existing file from the chosen directory and this name will be in the File Name Text box, or they just double-click the file they wish to overwrite, which is the same as selecting the file and clicking save.

This was the behavior in 2.4.

Now in 2.5

Clicking the folder icon opens a different File Save Window.

Selecting the file does nothing for the Name text box. Users have to type test.json in the name box to select an existing file. However double-clicking on the file does something weird:

It selects the directory where the file is stored, but not the file. When running the tool, it tries to delete the directory.
In this case, the path is short, but with long file path's the users might not notice that after a double click the file name is not in the path

I discussed this issue with my local support: one of the suggestions was to set parameter direction to input. This gives the desired behavior, but my users cannot create new files. Only existing files can be selected.

The final feedback I got from local support:

“After watching that video you created I can see what is causing this issue.  When the direction for the tool is set to Input, an input must be specified.  The tool is throwing an error because you are specifying an input that doesn't exist. 

 

This brings us to another reality about this tool, and all tools in general.  When the direction is set to Input, a pre-existing file must be specified.  You can't input something that doesn't exist.  When you specify this Input, it will populate the parameter with the full path.  When the direction is set to Output, you can specify a file that doesn't exist and therefore have a file created.  However, if you want to overwrite an existing file, you will have to type the name of that file in manually. 

 

This is an unavoidable trade off between the two methods.  With the Input direction, the full path of the pre-existing file will auto populate the parameter, but a new file cannot be created.  With the Output direction, a new file can be generated, but if you want to overwrite an existing file, the file name will have to be typed in.  It is up to the user as to which method best fits his needs.  “

I disagree with the design decision to force users to type the file name. In my opinion, the old File Save Window worked perfect and therefore should return, or the new one should behave the same when selecting and double clicking files. 

So please bring back the old Save File Window in Python toolboxes or make the new window behave the same!