Select to view content in your preferred language

10.1 List in Value Table in Python Toolbox

6896
12
05-01-2012 07:35 PM
GeorgeRaber
Emerging 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.
Tags (2)
12 Replies
by Anonymous User
Not applicable

I know this is an old post, but I have been struggling with this as well and wanted to post a solution.  I was able to figure out a very clunky workaround that does allow you to create your own drop down.  In my case, I did not actually use a "Field" value for the first part of the drop down but rather a list of Land use values derived from an input table's field values.

By using suggestions from David Wynne above, I was able to "trick" the GP framework with a Python toolbox.  I made a copy of the Summary Statistics parameter as suggested, then modified the parameter filter lists like this:

parameters[7].filters[1].list = ['some_list', ...]

And the relevant code:

# global var
CURVE_NUMS = [[u'Agricultural', 30.0, 58.0, 71.0, 80.0, 30.0], ...]# more values ommitted
    
    def getParameterInfo(self):
         fmap = arcpy.GetParameterInfo("Statistics_analysis")[2]
         
    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        if parameters[4].value:
            if parameters[4].valueAsText != LULC_FIELD and not parameters[6].altered:
                setattr(sys.modules[__name__], LULC_FIELD, parameters[4].valueAsText)

                with arcpy.da.SearchCursor(parameters[3].valueAsText, [parameters[4].valueAsText]) as srows:
                    lulc_vals = sorted(list(set([str(r[0]) for r in srows]))) # get land use values from field

                parameters[6].values = CURVE_NUMS

                # create dummy table
                parameters[7].value = [[l, ' '] for l in lulc_vals]  #assign a default of " " so the user can fill in drop down
                parameters[7].filters[1].list = [r[0] for r in CURVE_NUMS]  # IMPORTANT, update the filter list from summary stats to your own list


        return

value_table1.PNG

And the drop down:

value_table2.PNG

This is not customizable, as you can only use the two columns and you cannot rename the parameter, but it does work.  Hopefully Esri supports this behavior in the future.

It would be nice if you could set a list filter for multiple columns like this:

parameters.filter.list = [[list1,...], [list2]]
JasonXue
Deactivated User

Could you tell me how to make a parameter like this as I circled as below? I need to a parameter can be used to show a table content? Thanks.

0 Kudos
curtvprice
MVP Esteemed Contributor
0 Kudos