Tuesday, 12 September 2017

arcpy - Controlling Categories in Script Validation Tools - Expanding Groups By Default


The validation tab in your script tool properties allows you to put parameters in categories. The help states:



Put parameters in different categories. Categories are expandable window shades with a collection of parameters.



enter image description here


I am using the categories to organize my parameters, so I don't care about the expandable/collapsible feature; it just adds a lot of time to the user. This is all within a normal toolbox, not a script toolbox. v10.1



Does anyone know how to have these categories expanded by default?


Here is my only validation code. I am only utilizing categories. The other parts are the default.


def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
self.params[0].category = "General"
self.params[1].category = "General"
self.params[2].category = "Inudaciones"
self.params[3].category = "Cienegas"
self.params[4].category = "DrenajesPrincipal"

self.params[5].category = "DrenajesSensillos"
self.params[6].category = "Inudaciones"
self.params[7].category = "Cienegas"
self.params[8].category = "DrenajesPrincipal"
self.params[9].category = "DrenajesSensillos"
return

Answer



This isn't possible in python, but you can by using a custom stylesheet.





  1. Copy "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Stylesheets\MdDlgContent.xsl" to the same folder as your script.




  2. Edit line 467 to remove STYLE="display:'none';", i.e. change:




    to






  3. Then in your script tool properties, set the stylesheet property to your edited.xsl.


    enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...