Re: CW_BGROUP and NONEXCLUSIVE [message #28137] |
Mon, 26 November 2001 04:12  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Ralf Schaa wrote:
>
> Cheers!
> I have this little problem with CW_BGROUP and the parameter /NONEXCLUSIVE:
> as far as i know the buttons can have two values (on=1, and off=0) , so how
> can i tell my program, that if when the status of the button is 'on' that he
> does something (for testing: print, 'on' and otherwise print, 'off') ..see
> the source below how i tried to solve it..seems logical to me, but it
> doesn't work....
>
> thanx for any help!
> ralf
Dear Ralf,
I have written a compound widget for Buttons,
cw_buttons
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/cw_buttons.tar.gz
e.g.
value={value:['Switch1','Switch2'],set:[0,1]}
b=cw_buttons(a,value=value,uvalue='EF',col=2,/nonexclusive,f rame=2,xoffset=20,yoffset=0,button_frame=1)
regards
Reimar
PRO test_event,ev
WIDGET_CONTROL,ev.id,get_uval=cmd
WIDGET_CONTROL,ev.top,get_uvalue=b
CASE cmd OF
'done':WIDGET_CONTROL,ev.top,/dest
'FF': BEGIN
WIDGET_CONTROL,ev.id,get_value=v
print,v.set
idx=(WHERE(v.set EQ 1,count))[0]
IF count GT 0 THEN BEGIN
value={value:[strtrim(SINDGEN(idx+1),2)],set:MAKE_ARRAY(idx+ 1,/LONG,value=1)}
WIDGET_CONTROL,b,set_value=value
ENDIF
END
ELSE:
ENDCASE
END
PRO test
a=WIDGET_BASE(row=2)
value={value:['MIN','SPEC','DEFAULT','MAX'],set:[1,0,0,0]}
b=cw_buttons(a,value=value,uvalue='FF',row=1,button_xsize=60 ,frame=2,xoffset=0,yoffset=0,button_frame=1)
value={value:['0'],set:[1]}
b=cw_buttons(a,value=value,uvalue='EF',col=2,/nonexclusive,f rame=2,xoffset=20,yoffset=0,button_frame=1)
d=WIDGET_BUTTON(a,val='done',uval='done')
WIDGET_CONTROL,/realize,a,set_uvalue=b
XMANAGER,'test',a
END
>
> ;======================
> COMMON drawbutton, draw
> draw = {onoffpanel: fltarr(4) }
> draw.onoffpanel = [0,0,0,0] <---my predefined values
>
> ;============================================
> ; defined in the main-programm
> ;============================================
> onoffpanel=CW_BGROUP(container1,['sat1','sat2','sat3','sat4' ],$
> /NONEXCLUSIVE, $
> FONT=font,/RETURN_INDEX,$
> UVALUE='onoff',SET_VALUE=draw.onoffpanel, $
> COLUMN=4,LABEL_TOP='sat-plot: ',/FRAME)
>
> ;======================================
> ; defined in the event_programm
> ;======================================
>
> WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
>
> CASE Ev OF
> 'onoff': BEGIN
> draw.onoffpanel= event.value
> CASE draw.onoffpanel(0) OF
> 0: PRINT, 'sat1:off'
> 1: PRINT, 'sat1:on'
> ENDCASE
> CASE draw.onoffpanel(1) OF
> 0: PRINT, 'sat2:off'
> 1: PRINT, 'sat2:on'
> ENDCASE
> CASE draw.onoffpanel(2) OF
> 0: PRINT, 'sat3:off'
> 1: PRINT, 'sat3:on'
> ENDCASE
> CASE draw.onoffpanel(3) OF
> 0: PRINT, 'sat4:off'
> 1: PRINT, 'sat4:on'
> ENDCASE
> ENDCASE
> ENDCASE
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|
|
Re: CW_BGROUP and NONEXCLUSIVE [message #28144 is a reply to message #28142] |
Sat, 24 November 2001 06:55   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ralf Schaa (schaa@geo.uni-koeln.de) writes:
> I have this little problem with CW_BGROUP and the parameter /NONEXCLUSIVE:
> as far as i know the buttons can have two values (on=1, and off=0) , so how
> can i tell my program, that if when the status of the button is 'on' that he
> does something (for testing: print, 'on' and otherwise print, 'off') ..see
> the source below how i tried to solve it..seems logical to me, but it
> doesn't work....
I don't use CW_BGROUP, so I can't really help you with
how that works, but I think most of your problem lies
in this part of your code:
> CASE Ev OF
> 'onoff': BEGIN
> draw.onoffpanel= event.value
That last statement is effectively turning
all of your buttons ON or all of your buttons OFF,
based on the value from a single button. The problem
you have is that you don't know which button that
was.
IDL> draw = {onoffpanel: fltarr(4) }
IDL> print, draw.onoffpanel
0.000000 0.000000 0.000000 0.000000
IDL> draw.onoffpanel = 1
IDL> print, draw.onoffpanel
1.00000 1.00000 1.00000 1.00000
You probably want to know which button was selected,
so you can change the proper value in your onoffpanel
field. Maybe something like this:
Widget_Control, event.id, Get_Value=buttonValue
CASE buttonValue OF
'Sat1': draw.onoffpanel[0] = event.value
'Sat2': draw.onoffpanel[1] = event.value
'Sat3': draw.onoffpanel[2] = event.value
'Sat4': draw.onoffpanel[3] = event.value
ENDCASE
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: CW_BGROUP and NONEXCLUSIVE [message #28242 is a reply to message #28137] |
Tue, 27 November 2001 23:09  |
Ralf Schaa
Messages: 37 Registered: June 2001
|
Member |
|
|
Vielen Dank nach J�lich, funktioniert wunderbar!
Sch�nen Gruss
Ralf
"Reimar Bauer" <r.bauer@fz-juelich.de> schrieb im Newsbeitrag
news:3C0231B7.729D3522@fz-juelich.de...
> Ralf Schaa wrote:
>>
>> Cheers!
>> I have this little problem with CW_BGROUP and the parameter
/NONEXCLUSIVE:
>> as far as i know the buttons can have two values (on=1, and off=0) , so
how
>> can i tell my program, that if when the status of the button is 'on'
that he
>> does something (for testing: print, 'on' and otherwise print, 'off')
..see
>> the source below how i tried to solve it..seems logical to me, but it
>> doesn't work....
>>
>> thanx for any help!
>> ralf
>
> Dear Ralf,
>
> I have written a compound widget for Buttons,
> cw_buttons
>
>
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/downl
oad/cw_buttons.tar.gz
>
> e.g.
> value={value:['Switch1','Switch2'],set:[0,1]}
>
>
b=cw_buttons(a,value=value,uvalue='EF',col=2,/nonexclusive,f rame=2,xoffset=2
0,yoffset=0,button_frame=1)
>
>
>
> regards
> Reimar
>
> PRO test_event,ev
>
> WIDGET_CONTROL,ev.id,get_uval=cmd
> WIDGET_CONTROL,ev.top,get_uvalue=b
> CASE cmd OF
> 'done':WIDGET_CONTROL,ev.top,/dest
> 'FF': BEGIN
> WIDGET_CONTROL,ev.id,get_value=v
> print,v.set
> idx=(WHERE(v.set EQ 1,count))[0]
> IF count GT 0 THEN BEGIN
>
>
value={value:[strtrim(SINDGEN(idx+1),2)],set:MAKE_ARRAY(idx+ 1,/LONG,value=1)
}
> WIDGET_CONTROL,b,set_value=value
> ENDIF
> END
>
> ELSE:
> ENDCASE
> END
> PRO test
>
> a=WIDGET_BASE(row=2)
> value={value:['MIN','SPEC','DEFAULT','MAX'],set:[1,0,0,0]}
>
>
b=cw_buttons(a,value=value,uvalue='FF',row=1,button_xsize=60 ,frame=2,xoffset
=0,yoffset=0,button_frame=1)
> value={value:['0'],set:[1]}
>
>
b=cw_buttons(a,value=value,uvalue='EF',col=2,/nonexclusive,f rame=2,xoffset=2
0,yoffset=0,button_frame=1)
>
> d=WIDGET_BUTTON(a,val='done',uval='done')
> WIDGET_CONTROL,/realize,a,set_uvalue=b
> XMANAGER,'test',a
> END
>
>>
>> ;======================
>> COMMON drawbutton, draw
>> draw = {onoffpanel: fltarr(4) }
>> draw.onoffpanel = [0,0,0,0] <---my predefined values
>>
>> ;============================================
>> ; defined in the main-programm
>> ;============================================
>> onoffpanel=CW_BGROUP(container1,['sat1','sat2','sat3','sat4' ],$
>> /NONEXCLUSIVE, $
>> FONT=font,/RETURN_INDEX,$
>> UVALUE='onoff',SET_VALUE=draw.onoffpanel, $
>> COLUMN=4,LABEL_TOP='sat-plot: ',/FRAME)
>>
>> ;======================================
>> ; defined in the event_programm
>> ;======================================
>>
>> WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
>>
>> CASE Ev OF
>> 'onoff': BEGIN
>> draw.onoffpanel= event.value
>> CASE draw.onoffpanel(0) OF
>> 0: PRINT, 'sat1:off'
>> 1: PRINT, 'sat1:on'
>> ENDCASE
>> CASE draw.onoffpanel(1) OF
>> 0: PRINT, 'sat2:off'
>> 1: PRINT, 'sat2:on'
>> ENDCASE
>> CASE draw.onoffpanel(2) OF
>> 0: PRINT, 'sat3:off'
>> 1: PRINT, 'sat3:on'
>> ENDCASE
>> CASE draw.onoffpanel(3) OF
>> 0: PRINT, 'sat4:off'
>> 1: PRINT, 'sat4:on'
>> ENDCASE
>> ENDCASE
>> ENDCASE
>
> --
> Reimar Bauer
>
> Institut fuer Stratosphaerische Chemie (ICG-1)
> Forschungszentrum Juelich
> email: R.Bauer@fz-juelich.de
> http://www.fz-juelich.de/icg/icg1/
> ============================================================ ======
> a IDL library at ForschungsZentrum Juelich
> http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
>
> http://www.fz-juelich.de/zb/text/publikation/juel3786.html
> ============================================================ ======
>
> read something about linux / windows
> http://www.suse.de/de/news/hotnews/MS.html
|
|
|