[This followup was also posted to comp.lang.idl-pvwave]
Irene Barg (barg@nickel.as.arizona.edu) writes:
> Can anyone give me an working example of how to use CW_FORM?
[...Pretty ugly code with COMMON blocks snipped. :-)...]
Here you go.
PRO testform_Event, event
COMMON params, fsize, fname
COMMON b_ids, b
CASE event.tag OF
'OK': begin
Widget_Control, event.id, Get_Value=alltags
fsize = alltags.fsize
fname = alltags.fname
WIDGET_CONTROL, event.top, /DESTROY
end
ELSE: ; Drop through event handler
ENDCASE
END
PRO testform
COMMON b_ids, b
COMMON params, fsize, fname
; describe my form
DESC = [ $
'0, LABEL, Centered Label, CENTER', $
'1, BASE,, ROW, FRAME', $
'0, BUTTON, B1|B2|B3, LABEL_TOP=Nonexclusive:, COLUMN, TAG=bg1', $
'2, BUTTON, E1|E2|E3, EXCLUSIVE, LABEL_TOP=Exclusive:, COLUMN, TAG=bg2',
$
'0, TEXT, , LABEL_LEFT=Enter File name:, WIDTH=12, TAG=fname', $
'0, INTEGER, 0, LABEL_LEFT=File size:, WIDTH=12, TAG=fsize', $
'1, BASE,, ROW', $
'0, BUTTON, OK, QUIT, FONT="helvetica", TAG=OK', $
'2, BUTTON, Cancel, QUIT']
a = WIDGET_BASE(TITLE='Testing IDL forms')
b = CW_FORM(a, desc, /COLUMN)
WIDGET_CONTROL, a, /REALIZE
XMANAGER, 'TESTFORM', a
print, 'Filesize: ', fsize
print, 'Filename: ', fname
END
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|