10.1 List in Value Table in Python Toolbox

5882
12
05-01-2012 07:35 PM
GeorgeRaber
New Contributor II
I am trying to create a Python Toolbox in ArcGIS 10.1 and can't seem to replicate something like what I see in the Summary Statistics tool where the user builds a Value Table that contains a list of Fields and then within the table the user must pick from a list of valid Statistic types (SUM, MEAN, etc).  Anyone have an idea or experience doing this?  Thanks.
Tags (2)
12 Replies
DavidWynne
Esri Contributor
I am trying to create a Python Toolbox in ArcGIS 10.1 and can't seem to replicate something like what I see in the Summary Statistics tool where the user builds a Value Table that contains a list of Fields and then within the table the user must pick from a list of valid Statistic types (SUM, MEAN, etc).  Anyone have an idea or experience doing this?  Thanks.


Unfortunately, adding a drop-down of keywords is not supported at the moment in a Python toolbox value table parameter.  The way it's implemented right now, the closest that can be done would be to validate the column in updateMessages and add messages to the parameter indicating the choices.  Admittedly that's far from ideal. 

If you want to create an exact match of the Summary Statistic tool's value table parameter that is a little easier.  You could mine the parameter from the tool using the arcpy.GetParameterInfo function and use that in python toolbox tool's getParameterInfo.  Something like this below:

    def getParameterInfo(self):
        in_table = arcpy.Parameter(
            name="in_table",
            displayName="Input Table",
            datatype="Table View",
            direction="Input",
            parameterType="Required")
        
        stats_field = arcpy.GetParameterInfo("Statistics_analysis")[2]
        stats_field.parameterDependencies = [in_table.name]

        return [in_table, stats_field]


-Dave
0 Kudos
NikolayVladimirovich
New Contributor
Hello, are there any progress in this matter? I interested in realization "Obtained from" for multiple values. Like in "Topo to raster" for feature and Z-field. Sorry for bad english.
- Nick
0 Kudos
MelanieMaguire
New Contributor III
Thanks Dave.  I will have to try that out.  George, there is also a summary statistics tool in the statistics toolbox that you might be interested in.  http://resources.arcgis.com/en/help/main/10.1/index.html#/Summary_Statistics/00080000001z000000/
0 Kudos
JamieKass
Occasional Contributor
This is a good quick fix, but I would very much like the functionality available to replicate any tool GUI behavior in a python toolbox, especially the ability to have the user select values from a multivalue string list that gets returned as a list.
0 Kudos
NikolayVladimirovich
New Contributor
Still no answer?
0 Kudos
TimDonoyou
Occasional Contributor
Hi All,

Appreciate this is an old thread but any progress on this? has it been solved in 10.2?

I have looked at the help menus but it doesn't give any more information than 10.1 version.

If possible I would like a 2 column input table - column 1 will be a habitat type selected from a dropdown and then column 2 would be a species selected from another dropdown whose values would change depending on the habitat selected for column 1.

Cheers

Tim
0 Kudos
RichardFairhurst
MVP Honored Contributor
Here are two blogs on the subject.  Generating a choice list from a field. and Generating a multivalue choice list..  I know there was another blog that laid the process out better that I used, but I have not been able to find it so far.

Generally interactive list dependencies are handled in the tool Validation script.  I have done this in the past and created tools where user interaction with one component of a tool updated a choice list in another part of the tool.  It worked OK when I did this for a two field dependency.  You have to be pretty skilled at Python to make it work really well since once you understand the principles there are many subtle adjustments that can customize the list behaviors beyond what the blogs cover.  Testing and modifying the tool is not well supported so I am not willing to instruct a Python novice on how to set it up and customize it through the forum.  Get comfortable with Python before attempting this.

But the principles for modifying the tool validation do not scale well as you make your tool increasingly complex.  When I got to about 7 field interactions on a single tool I needed over 700 lines of validation code to make the interactions work the way I wanted.  The performance of the tool tanked to the point where it took 5 to 10 minutes just to load the tool for editing and it took minutes to run.  At that point I abandoned the tool and ended up going to .Net Add-ins.  .Net has no problem with very complex forms, gave me a lot more interface options and performs great.  So for really involved user interfaces that go beyond simple two field interactions you should create add-ins with .Net that use Windows forms and UI components.
0 Kudos
TimDonoyou
Occasional Contributor
Hi Richard

Many thanks for your advice and links - really helpful.

While I admit I am not a python expert I have created scripts to automate many of our workflows and have included validation scriptswith these so have more than a basic knowledge.

What I am hoping to achieve is a combination of using a featureset and recordset or attribute lists to add multiple species to a ecology habitat type...the user will click a point to add a habitat type which can be from a feature template or a list parameter...the habitat type selected will determine the species list dropdown - i can do this already using the vaildation script to change the species tick list...BUT...if possible I would really like to also include an abundance attribute (D, A, F, O, R) for each species and this is not possible at the moment as the value list defaults to a ticklist - do you know if it is possible to create a value table for string parameters?

or would I be better off going the .net route? if so where is the best place to get started?

Any pointers are much appreciated.

Cheers

Tim
0 Kudos
RichardFairhurst
MVP Honored Contributor
Hi Richard

Many thanks for your advice and links - really helpful.

While I admit I am not a python expert I have created scripts to automate many of our workflows and have included validation scriptswith these so have more than a basic knowledge.

What I am hoping to achieve is a combination of using a featureset and recordset or attribute lists to add multiple species to a ecology habitat type...the user will click a point to add a habitat type which can be from a feature template or a list parameter...the habitat type selected will determine the species list dropdown - i can do this already using the vaildation script to change the species tick list...BUT...if possible I would really like to also include an abundance attribute (D, A, F, O, R) for each species and this is not possible at the moment as the value list defaults to a ticklist - do you know if it is possible to create a value table for string parameters?

or would I be better off going the .net route? if so where is the best place to get started?

Any pointers are much appreciated.

Cheers

Tim


I know that the validation for the second combobox drop down uses a cursor to get the value list.  The drop down list can be modified at runtime with string values.  I have a sample tool with two coordinated drop downs at work, but cannot access it at the moment.  In any case, it should be possible using either the tool or .Net as long as you don't need to continue expanding the interface with a lot more runtime updates.  As I said, .Net works much better for many controls that interact with your databases at runtime.

A value table of multiple columns does not work as far as I know in the tool.  At the very least I never found any documentation that explained how to get the tool to emulate such things as the Sort tool table parameters. .Net can handle it with listbox or datagrid tools.
0 Kudos