Style Sheets for User Interface Elements

If you create a custom task that displays a dialog for selecting parameters for an ENVITask or custom API script, you can include a style sheet to define the individual user interface (UI) elements. Examples of UI elements include file selection boxes, color pickers, and text boxes.

Normally if a custom task displays a dialog, the task will make a best guess at determining an appropriate UI element to display for a specific parameter. By specifying a style sheet, you have more flexibility in choosing UI elements for each input and output parameter for your custom task.

Style sheets consist of JSON-formatted text that maps task parameters to UI elements. See User Interface Elements for a complete list.

Here is a simple example of a style sheet:

{

   "schema": "envitask_3.3",

   "show_preview": false,

   "show_display_result": true,

   "parameters": [

     {

       "name": "raster_filename",

       "type": "IDLLabel_UI"

     }

   ]

}

Style Sheet Keys

This table describes the various fields (also called keys) in a style sheet.

Key

Description

schema

A string listing the version of ENVITask JSON schema that was used to write this task. The valid values are envitask_3.3, envitask_3.2, envitask_3.1, or envitask_3.0.

show_display_result

Set this key to true to display the Display result check box. Or set it to false to hide the check box.

show_preview

Set this key to true to display the Show Preview check box. Or set it to false to hide the check box.

show_read_more

Set this key to true to display the Read more hyperlink in the help dialog that displays when the user clicks the Help button. Or set it to false to remove the Read more text and hyperlink.

parameters

A container of key/value pairs, described in the Parameter Keys table below.

tab_groups

A set of key/value pairs, where the key is the label of the tab and the value is an array of parameter names to be included in each tab. For example, to separate your dialog into two tabs or groups called “Main” and “Advanced”, do the following:

"tab_groups": {
     "Main": ["parameter_name_1", " parameter_name_2"],
     "Advanced": ["parameter_name_3", " parameter_name_4"]
   },

Where [parameter_name_x] are the names of your task parameters that need to go on each tab.

Parameter Keys

This table describes the keys that belong to the parameters group in a style sheet. Repeat for each parameter.

Key

Description

name

The name of the parameter. This name must exactly match the parameter name in the corresponding task template.

type

Set this key to the name of a UI element to display for the parameter. See User Interface Elements.

If you are unsure what type to specify and you want to see a preview, use the ENVIUI::CreateFromDialog method to display it. For example:

e = ENVI()

ui = e.UI

element = ENVIColorMapName_UI()

result = envi.ui.CreateFromDialog(element)

Steps to Create a Style Sheet

Follow these steps:

  1. Copy and paste the example above into a new text file.
  2. Repeat the parameters group for each input and output parameter in your custom task, then update the name and type keys. See the Parameter Keys table above.
  3. Save the template with a .style file extension to the same folder as the task file. If you save the template to another location, set the ENVIUI::SelectTaskParameters STYLE_SHEET keyword to point to that location.

When you run your custom task, the dialog will contain the new elements that you defined.