Widget programing - Please help! [message #85854] |
Fri, 13 September 2013 21:46  |
moxament
Messages: 26 Registered: April 2008
|
Junior Member |
|
|
Deal All,
I am writing a simple widget program in IDL where the user is to select between two files: file one and file two. The code is below:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;
pro span, event
compile_opt idl2
;Define the main widget and its childs
main = WIDGET_BASE(Title = "Select Input File", XSIZE=260, /COLUMN)
values = ["file one", "file two"]
select = CW_BGROUP(main, values, /EXCLUSIVE)
line = WIDGET_BASE(main,column=3)
okay = WIDGET_BUTTON(line,VALUE=' Okay ',xsize=120)
cancel = WIDGET_BUTTON(line,VALUE=' Cancel ', xsize=120)
;Realize the widget
WIDGET_CONTROL, main, /REALIZE, tlb_get_size = tlb_size
WIDGET_CONTROL, select, GET_VALUE=val
screen_dim = GET_SCREEN_SIZE()
WIDGET_CONTROL, main, xoffset = screen_dim[0]/2 - fix(tlb_size[0]/2), yoffset = screen_dim[1]/2 - fix(tlb_size[1]/2)
event1 = WIDGET_EVENT(line)
CASE event1.id of
cancel: widget_control, event1.top, /destroy
okay : begin
event2 = WIDGET_EVENT(select)
WIDGET_CONTROL, select, GET_VALUE = val
if val eq 0 then print, "file one selected"
if val eq 1 then print, "file two selected"
end
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;
Now, my question is that how can I include the case where the user might click by mistake the button "Okay" without the selection of any of the two files. In case of this mistake by the user, I would like an error message to appear and say:
"ERROR: Please select one of the two files"
Your help is appreciated!
Khal.
|
|
|