Creating a new Python tool is too complicated

637
11
08-13-2011 05:24 PM
KimOllivier
Occasional Contributor III
I tend to create a new tool in a 'top-down' process:

  • Create a new toolbox

  • Add a new tool

  • Add in the parameters

  • Edit the documentation for the general purpose

  • Open the script to start writing

At Win 7 this has got even harder if you do not have Administrator access to streamline Windoze.

"Adding" a script is not appropriate because I have yet to create the script.
It would be useful to be able to create an empty file with a py suffix right there.

In the absence of a create, you can open the folder with the common dialog and create a text file on the fly and change the name and extension. Then select your new file. But this is impossible unless file extension types have been made visible in Windows control panel. This could also be eased if a file type of Python script was added to the registry so you could create a python script file as an option.

The only other way is to open PythonWin separately and save a script before you start a new tool.
That is not very integrated and is confusing when teaching students. It should be possible to work entirely inside ArcMap to manage the whole toolbox/scripting process.
Tags (2)
0 Kudos
11 Replies
ChrisFox3
Occasional Contributor III
Hi Kim,

How about the opposite, work entirely outside of ArcMap to create your toolbox and script tools. This is the idea behind Python Toolboxes at 10.1. everything you need to define the Toolbox, the script tools, their paramaters, validation and execution code all in one python script. I would encourage you to check it out because although you know longer have the wizard to step you through the creation of the script tool, it is really more convienent to manage everything in the one python script.
0 Kudos
KimOllivier
Occasional Contributor III
We all would if we could, but the AddIn Python Wizard is not downloadable. Could you get this fixed?

http://forums.arcgis.com/threads/36026-Python-AddIn-Wizard-download-refused

It would still be useful to be able to create a (blank) python script as part of the tool wizard. Just think of all the script kiddies trying to write their first tool and script in the "Geoprocessing With Python" class.
0 Kudos
ChrisFox3
Occasional Contributor III
Hi Kim,

Here is the correct link to get the python add-in wizard. However, python add-ins are different then python toolboxes. Python add-ins allow you to build custom ui elements like buttons and toolbars with arcpy.

For more information on Python Toolboxes I would encourage you to check out the following help topic, What is a Python Toolbox.

For the request to create a blank python script as part of the script tool wizard I would recommend you post the idea on ideas.arcgis.com as there may be more people who would be interested in that functionality as well.

-Chris
0 Kudos
DanPatterson_Retired
MVP Emeritus
Chris
Are you suggesting that we can get some of the functionality of the old "Dialog Designer" days which harken back to AV3.x with add-ins?   Is this a Tkinter interface? Any more background docs? (haven't got beta 10.1 loaded yet so sorry if this is obvious)
0 Kudos
ChrisFox3
Occasional Contributor III
Hi Dan,

No not quite, unfortunately there is no supported python module at this time for building GUIs with python add-ins. So if you need to build a button that displays a form to accept user input and execute some code you will still need to use .Net or Java add-ins for Desktop.

However, there are many powerful things you can do with python add-ins. For example if you want to listen and respond to certain application events, like onDeleteFeature or onCreateFeature you can do that with a python add-in application extension.

Or if you want to create a tool that allows the user to draw a rectangle on the map to return an extent object and execute some python code based on the user input you can do that with a python add-in tool

More than just the functionality is the fact that python add-ins take advantage of the same framework for .Net and Java add-ins which makes it very easy to share and install these customizations.
0 Kudos
DanPatterson_Retired
MVP Emeritus
Thanks for the info Chris, I was more interested in the event-based things, I can use non-Java-Net for form development...will have a serious look at this since it opens up a whole realm of new application possibilities.
Regards
Dan
0 Kudos
DavidWynne
Esri Contributor
"Adding" a script is not appropriate because I have yet to create the script.
It would be useful to be able to create an empty file with a py suffix right there.


When you set a script tool's source--you should be able to specify a .py file that doesn't yet exist.  When you then hit the Next button, it will prompt you to create the empty .py file.

-Dave
0 Kudos
MoragHawkins
New Contributor II
Hi Dan,

No not quite, unfortunately there is no supported python module at this time for building GUIs with python add-ins. So if you need to build a button that displays a form to accept user input and execute some code you will still need to use .Net or Java add-ins for Desktop.



Are there plans for this before final release? Even 'simple' dialogs like an add-in option pane will be needed for many use cases, and will keep a lot of people staying with deploying toolboxes with parameters instead. Filling an addin toolbar with loads of buttons, menus and combos just to allow a user to specify even just half a dozen parameters will not look great.

Great first step though, good to see python addins
0 Kudos
ChrisFox3
Occasional Contributor III
Are there plans for this before final release? Even 'simple' dialogs like an add-in option pane will be needed for many use cases, and will keep a lot of people staying with deploying toolboxes with parameters instead. Filling an addin toolbar with loads of buttons, menus and combos just to allow a user to specify even just half a dozen parameters will not look great.

Great first step though, good to see python addins


Right now what we have in terms of simple dialogs are available with the pythonaddins module. With this module you have the ability to open a dialog which the user can browse to select one or more datasets and return the path of the users selection to the tool. The same can be done so the user can save the path of a new dataset. You can also create a message with optional buttons such as Yes/No, OK/Cancel to get the users input.
0 Kudos