The CW_FILESEL is a compound widget which can be used in a component fashion as well as adding multiple file filter selection. The following example illustrates how CW_FILESEL could be used to create a widget for opening image files:
PRO image_opener_event, event
WIDGET_CONTROL, event.top, GET_UVALUE=state, /NO_COPY
CASE event.DONE OF
0: BEGIN
state.file = event.VALUE
WIDGET_CONTROL, event.top, SET_UVALUE=state, /NO_COPY
END
1: BEGIN
IF (state.file NE '') THEN BEGIN
img = READ_IMAGE(state.file)
TV, img
ENDIF
WIDGET_CONTROL, event.top, SET_UVALUE=state, /NO_COPY
END
2: WIDGET_CONTROL, event.top, /DESTROY
ENDCASE
END
PRO image_opener
DEVICE, DECOMPOSED=0, RETAIN=2
base = WIDGET_BASE(TITLE ='Open Image', /COLUMN)
filesel = CW_FILESEL(base, /IMAGE_FILTER, FILTER='All Files')
file=''
state = {file:file}
WIDGET_CONTROL, base, /REALIZE
WIDGET_CONTROL, base, SET_UVALUE=state, /NO_COPY
XMANAGER, 'image_opener', base
END
This code opens the following dialog: