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 |
show_display_result |
Set this key to |
show_preview |
Set this key to |
show_read_more |
Set this key to |
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 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:
- Copy and paste the example above into a new text file.
- Repeat the
parameters
group for each input and output parameter in your custom task, then update thename
andtype
keys. See the Parameter Keys table above. - 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.