auto_wid_mng and 'Invalid widget identifier' [message #82455] |
Fri, 14 December 2012 13:13 |
dunstan8986
Messages: 1 Registered: December 2012
|
Junior Member |
|
|
I'm trying to write some ENVI/IDL code to prompt the user for a few values and
do some computation on those values after they've all been entered. The GUI
looks fine and everything works as I expect until I click on OK & try to get
values out of the widgets. At that point I get an 'Invalid widget identifier'
message.
In the real code I prompt for two input files, one of them an image file from
which I get & display band info, and have the user pick one of the bands. The
user also enters a floating-point value, and the name of an output file. The
simplified code below exhibits all the errors I'm encountering, however.
------------------ start code ----------------------------
; Respond to the users' clicking the 'Browse...' button.
PRO pickFile, event
; Get the ID of the button widget
widget_control, event.id, get_uvalue=textFieldId
; Get the current filename.
widget_control, textFieldId.textFieldId, get_value=oldfile
; Get the new filename
newfile = dialog_pickfile(file=oldfile, filter='*.zip', /must_exist, $
title='Pick .zip file')
if newfile ne '' then begin
; Update the filename string widget.
widget_control, textFieldId.textfieldId, set_value=newfile
end
end
; My menu item's main routine
PRO mycode, ev
compile_opt idl2, hidden
tlb = widget_auto_base(title='Sample Code')
; filename entry bits
file_base = widget_base(tlb, /row)
file_label = widget_label(file_base, /align_left, value='.zip file: ')
file_entry = widget_string(file_base, uvalue='file_entry')
file_btn = widget_button(file_base, event_pro='pickFile', value='Browse...', $
uvalue={textFieldId : file_entry})
; floating-point value entry bits.
param_base = widget_base(tlb, /row)
param_slider = widget_sslider(param_base, /auto_manage, ceil=2., max=50, min=0, scale=1./50., $
uvalue='param', title='Param value 0..2', dt=4, value=0.4)
; Let 'er rip!
result = auto_wid_mng(tlb)
print, 'Result: ', result
; If I clicked on "OK", at this point result only has two fields: PARAM and
; ACCEPT. No mention of FILE_ENTRY. Ok, I need to go get it from the
; widget itself...
widget_control, file_entry, get_value=filename
;... and I get an 'Invalid widget identifier'. Apparently auto_wid_mng
; destroys my widget before I can get anything out of it?
END
------------------ end code ----------------------------
I haven't shown what I did to make it show up in the ENVI menu but it does show
up, and looks fine up until I click OK.
To further confuse me, if I comment out the param_base & param_slider
parts I never even get my dialog box. Instead I get a stack trace saying:
Expression must be a structure in this context: INFO.
Execution halted at: AUTO_WID_MNG
MYCODE NN c:\path\to\my\source\code\mycode.pro
...more stack trace...
(where NN is the line number of the call to auto_wid_mng)
I'm using ENVI 8.0.1 on Windows XP.
I'm new at ENVI+IDL but have been writing Java, C++, etc for more years than I
care to remember. Any clues as to where I've gone wrong?
Thanks!
Al
|
|
|