IDLContainer_UI Examples
The IDLContainer_UI class provides a way to display multiple UI classes in one dialog. For example, the following code displays the ENVIRaster_UI and ENVIVector_UI classes together:
; Start the application
e = ENVI()
; Create the container
outUI = IDLContainer_UI()
; Define the elements of the container
outUI['raster'] = ENVIRaster_UI(TITLE='Input Raster')
outUI['vector'] = ENVIVector_UI(TITLE='Input Vector')
; Display the UI
result = e.UI.CreateFromDialog(outUI, TITLE='Select Input Files')
Result:
Set the ROW keyword in the call to IDLCotainer_UI to display both parameters in one row:
When users choose an Input Raster, it is assigned to the raster
variable. When they choose an Input Vector, it is assigned to the vector
variable.
The next example creates two smaller containers within an overall container. Each smaller container contains a mixture of different UI classes: ENVIRaster_UI, ENVIVector_UI, and IDLNumeric_UI. Use the CAN_TOGGLE keyword for IDLContainer_UI to let users hide or display the groups. You could use this example to hide several advanced parameters, for example, so that they do not occupy a lot of space in the UI.
; Create the overall container
outUI = IDLContainer_UI()
; Create groups of inputs, each based on different UI classes
outUI['group_1'] = IDLContainer_UI(/CAN_TOGGLE, /FRAME, TOGGLE_LABEL='Input Raster')
outUI['group_1', 'raster'] = ENVIRaster_UI(TITLE='Input Raster')
outUI['group_1', 'number'] = IDLNumeric_UI(TITLE='Input Number')
outUI['group_2'] = IDLContainer_UI(/CAN_TOGGLE, /FRAME, TOGGLE_LABEL='Input Vector')
outUI['group_2', 'vector'] = ENVIVector_UI(TITLE='Input Vector')
outUI['group_2', 'number'] = IDLNumeric_UI(TITLE='Input Number')
; Display the UI
result = e.UI.CreatefromDialog(outUI, TITLE='Select File and Numeric Inputs')
Result:
Note the use of the FRAME keyword, which separates each group by rectangular borders.
When users select input files and enter numeric values in this example, the resulting values are stored in a hash; for example:
Print, result, /IMPLIED
Result:
{
"group_1": {
"raster": <ObjHeapVar608395(ENVIRASTER)>,
"number": "3"
},
"group_2": {
"vector": <ObjHeapVar600408(ENVIVECTOR)>,
"number": "5"
}
}