X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



7738 Rate this article:
No rating

How to Add a New Button to the ENVI Menu


The following article shows how to add a custom button to a submenu under the ENVI main menu. The sample program below adds a custom menu called 'My Tools' and button called 'Get Some File Info' to the Basic Tools > Preprocessing menu:

Basic Tools > Preprocessing > My Tools > Get Some File Info

Clicking on this button will activate a dialog box prompting the user to select an image file. Some error handling code statements can catch invalid files. Basic file information will be output to the Workbench console tab and will contain the following:

- File dimensions in ENVI 'dims' format
- The number of samples in the image file
- The number of lines in the image file
- The number of bands in the image file

This file can be copied directly into the ENVI/IDL Workbench. Once saved and compiled it should be placed in the ENVI 'save_add' directory. Assuming a default installation on Windows XP this location would be:
C:\Program Files\ITT\IDL\IDLxx\products\envixx\save_add

The ENVI_DEFINE_MENU_BUTTON procedure is used to add menu items (buttons) to the ENVI menu system. This is accomplished through a *.pro file or *.sav file placed in the save_add directory. The syntax requires that the *.pro or *.sav file must contain the name of the main procedure followed by '_define_buttons'.
For example, if the file in the save_add directory is called 'Get_Some_FileInfo.pro' then the procedure to define the button will be 'Get_Some_FileInfo_define_buttons.pro'.

The button definition procedure allows for a variety of custom menu locations and button definitions in ENVI. For more options please see the ENVI_DEFINE_MENU_BUTTON procedure in the ENVI Help system.

The following example program shows the main procedure and the button definition procedure for a program called 'Get_Some_FileInfo':

; ++++++++++++++++++++++++++++
pro Get_Some_FileInfo_Define_Buttons,buttonInfo,buttonInfo

; Modified to incorporate access via main menu
; Error catch mechanism
compile_opt idl2

; Set up the button so the program can be used from the ENVI menu
envi_define_menu_button, buttonInfo, value = 'My Tools', $
/menu, ref_value = 'Preprocessing', ref_index=0, position = 'after'

envi_define_menu_button, buttonInfo, value = 'Get Some File Info', $
uvalue = 'Get Some File Info', event_pro = 'Get_Some_FileInfo', $
ref_value = 'My Tools', position = 'last'

END

; ++++++++++++++++++++++++++++

pro Get_Some_FileInfo,event

compile_opt idl2

;Get image file
file_name=dialog_pickfile(title='Input Image File')
if (file_name eq '') then
return

;Open the file
envi_open_file, file_name, r_fid=fid
if (fid eq -1) then return

;Query the file and get some basic information
envi_file_query, fid, dims=dims, ns=ns, nl=nl, nb=nb, $
xstart=xstart, ystart=ystart

print, ' *** File Info ***"
print, 'File dimensions are:', dims
print, 'Number of samples (x):', ns
print, 'Number of lines (y):', nl
print, 'Number of bands:', nb

END

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »