comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Trouble with CW_BGROUP events
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Trouble with CW_BGROUP events [message #48992] Sun, 11 June 2006 17:14 Go to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Hello all
New to IDL, kind of learning as I go. I am having trouble with a widget
interface, in which I want a set of radio buttons (created by
cw_bgroup) to control (among other things) the sensitivity of some
sliders. The buttons and sliders are located on a tab interface, but
are on the same tab. Whenever I trigger a event with the
"satview_GUI_changeAngle" code, it runs through fine once, but then
tries again to go through the code, (seemingly) without a second event.
I tried to /no_release keyword, but to no avail. Any ideas?

Thanks in advance for any help.


WIDGET CREATION CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
...
tabAngID = WIDGET_BASE(tabID, Event_Pro='satview_GUI_changeAngle')
;create the sliders for the angles of the CCD's
angle3ID=CW_FSlider(tabAngID,uvalue='angle3',uname='angle3')
angle4ID=CW_FSlider(tabAngID,uvalue='angle4',uname='angle4')
;create the radio buttons for the number of CCD's
numCCDID = CW_BGROUP(tabAngID,['1','2
(Default)'],button_uValue=[1,2],/exclusive,set_value=1,uvalu e='numofCCDs',/no_release)

EVENT HANDLER CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro satview_GUI_changeAngle,event

widget_control,event.id, get_value=buttonvalue,get_uvalue=userValue
CASE userValue OF
...
'numofCCDs' : BEGIN
angle3ID = widget_info(Event.top, find_by_uname='angle3')
angle4ID = widget_info(Event.top, find_by_uname='angle4')
CASE buttonvalue OF
'1' : widget_Control,angle3ID,SENSITIVE=0 &
widget_Control,angle4ID,SENSITIVE=0
END
'2' :widget_Control,angle3ID,SENSITIVE=1 &
widget_Control,angle4ID,SENSITIVE=1
END
ELSE:RETURN
ENDCASE
RETURN
END
ELSE : RETURN;do nothing
ENDCASE

end
Re: Trouble with CW_BGROUP events [message #49054 is a reply to message #48992] Wed, 14 June 2006 09:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Phillip Bitzer writes:

> I guess I forgot to mention that this was sample code, somewhat
> simplified with what I was trying to do. I actually have 3 choices,
> with values 1,2,4 (not just the 1,2), it might be expanded further. The
> boss-man isn't sure yet how many there will be.
>
> So you see I couldn't *quite* use the return index or some manipulation
> of it . . .

I would just build the menus yourself using WIDGET_BUTTON.
This way, you can send individual button events to different
event handlers and otherwise act as if you knew *exactly*
what you are doing. It is SO much easier! :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Trouble with CW_BGROUP events [message #49055 is a reply to message #48992] Wed, 14 June 2006 09:14 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
I guess I forgot to mention that this was sample code, somewhat
simplified with what I was trying to do. I actually have 3 choices,
with values 1,2,4 (not just the 1,2), it might be expanded further. The
boss-man isn't sure yet how many there will be.

So you see I couldn't *quite* use the return index or some manipulation
of it . . .

Again, you've been a great help, and I appreciate it.
Re: Trouble with CW_BGROUP events [message #49062 is a reply to message #48992] Tue, 13 June 2006 20:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Phillip Bitzer writes:

> I just got Fanning's Guide to IDL . . . I guess Widgets are the next
> purchase . . .

Widgets are in the back. But if you are looking for advice
on CW_BGROUP, don't ask me. I've never used it. :-(

Cheers,

David

P.S. Let's just say button groups are so easy to make
that I always just make them. I never have any problems
getting them to act like I expect them to. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Trouble with CW_BGROUP events [message #49063 is a reply to message #48992] Tue, 13 June 2006 20:21 Go to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Phillip Bitzer wrote:
> Thought of using the return_name keyword, but I wanted to use the
> number in other computations (not to mention the pesky 'Default'
> floating around).
>
> I just got Fanning's Guide to IDL . . . I guess Widgets are the next
> purchase . . .

/Return_index will give you 0 or 1 in your case of 2 buttons,
remembering that
IDL is a zero-based language, and will return an index in the range
[0..N_Buttons-1]

Andrew
Re: Trouble with CW_BGROUP events [message #49064 is a reply to message #48992] Tue, 13 June 2006 18:20 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Thought of using the return_name keyword, but I wanted to use the
number in other computations (not to mention the pesky 'Default'
floating around).

I just got Fanning's Guide to IDL . . . I guess Widgets are the next
purchase . . .
Re: Trouble with CW_BGROUP events [message #49065 is a reply to message #48992] Tue, 13 June 2006 15:58 Go to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Phillip Bitzer wrote:
> Thanks, everything works great now. Curious, why does cw_bgroup return
> 0 or 1 as the value? I was under the impression that if you specify the
> button_uvalue keyword, then the corresponding value would be returned
> (here 1 or 2).

Phillip,

Perhaps this might be better.

Remove the button_uValue, and insert /Return_Name

numCCDID = CW_BGROUP(tabAngID,['1','2(Default)'],$
/exclusive,set_value=1,$

uvalue='numofCCDs',/no_release,/frame,/return_name)

Then your Case statement can select on event.value as either '1' or
'2(Default)'

It's almost a case of CW_BGroup being over-optioned...

Andrew
Re: Trouble with CW_BGROUP events [message #49067 is a reply to message #48992] Tue, 13 June 2006 15:39 Go to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Phillip Bitzer wrote:
> Thanks, everything works great now. Curious, why does cw_bgroup return
> 0 or 1 as the value? I was under the impression that if you specify the
> button_uvalue keyword, then the corresponding value would be returned
> (here 1 or 2).

Phillip,

The online help says :-

BUTTON_UVALUE
An array of user values to be associated with each button and returned
in the event structure. If this keyword is set, the user values are
always returned, even if the any of the RETURN_ID, RETURN_INDEX, or
RETURN_NAME keywords are set.

Note : "returned in the event structure."

If you insert a help,/structure, event at the top of the event handler
procedure, then
you'll see something like this :-

ID LONG 20
TOP LONG 13
HANDLER LONG 13
SELECT LONG 1
VALUE STRING '2'

where the field event.value contains your stipulated button_uvalue,
hence
you could try :-

Case event.value of
'1'
'2'
etc

but that would would fail when the event is generated by another widget
that
doesn't have a Value field in its structure.

Have you read the Building Applications manual, or bought David
Fanning's book,
subtitled "The Joy of Widgets"?

Cheers,

Andrew
Re: Trouble with CW_BGROUP events [message #49078 is a reply to message #48992] Mon, 12 June 2006 19:45 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Thanks, everything works great now. Curious, why does cw_bgroup return
0 or 1 as the value? I was under the impression that if you specify the
button_uvalue keyword, then the corresponding value would be returned
(here 1 or 2).
Re: Trouble with CW_BGROUP events [message #49088 is a reply to message #48992] Mon, 12 June 2006 03:53 Go to previous message
A. D. & J.C. Cool is currently offline  A. D. & J.C. Cool
Messages: 16
Registered: February 2000
Junior Member
Phillip Bitzer wrote:
> Hello all
> New to IDL, kind of learning as I go. I am having trouble with a widget
> interface, in which I want a set of radio buttons (created by
> cw_bgroup) to control (among other things) the sensitivity of some
> sliders. The buttons and sliders are located on a tab interface, but
> are on the same tab. Whenever I trigger a event with the
> "satview_GUI_changeAngle" code, it runs through fine once, but then
> tries again to go through the code, (seemingly) without a second event.
> I tried to /no_release keyword, but to no avail. Any ideas?
>
> Thanks in advance for any help.
>
>
> WIDGET CREATION CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ...
> tabAngID = WIDGET_BASE(tabID, Event_Pro='satview_GUI_changeAngle')
> ;create the sliders for the angles of the CCD's
> angle3ID=CW_FSlider(tabAngID,uvalue='angle3',uname='angle3')
> angle4ID=CW_FSlider(tabAngID,uvalue='angle4',uname='angle4')
> ;create the radio buttons for the number of CCD's
> numCCDID = CW_BGROUP(tabAngID,['1','2
> (Default)'],button_uValue=[1,2],/exclusive,set_value=1,uvalu e='numofCCDs',/no_release)
>
> EVENT HANDLER CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> pro satview_GUI_changeAngle,event
>
> widget_control,event.id, get_value=buttonvalue,get_uvalue=userValue
> CASE userValue OF
> ...
> 'numofCCDs' : BEGIN
> angle3ID = widget_info(Event.top, find_by_uname='angle3')
> angle4ID = widget_info(Event.top, find_by_uname='angle4')
> CASE buttonvalue OF
> '1' : widget_Control,angle3ID,SENSITIVE=0 &
> widget_Control,angle4ID,SENSITIVE=0
> END
> '2' :widget_Control,angle3ID,SENSITIVE=1 &
> widget_Control,angle4ID,SENSITIVE=1
> END
> ELSE:RETURN
> ENDCASE
> RETURN
> END
> ELSE : RETURN;do nothing
> ENDCASE
>
> end

Phillip,

I've rearranged your code a little, and it works OK for me under IDL
6.3.

Andrew

pro satview_GUI_changeAngle_event,event

widget_control,event.id,
get_value=buttonvalue,get_uvalue=userValue

print,'uservalue = ',uservalue
print,'buttonvalue = ',buttonvalue

CASE userValue OF

'numofCCDs' : $
BEGIN
angle3ID = widget_info(Event.top,
find_by_uname='angle3')
angle4ID = widget_info(Event.top,
find_by_uname='angle4')

CASE buttonvalue OF
'0' : $
Begin
widget_Control,angle3ID,SENSITIVE=0
widget_Control,angle4ID,SENSITIVE=0
END

'1' : $
Begin
widget_Control,angle3ID,SENSITIVE=1
widget_Control,angle4ID,SENSITIVE=1
END
ELSE:RETURN
ENDCASE

RETURN
END ; of numofCCDs

ELSE :
ENDCASE

end

pro satview_GUI_changeAngle

tabAngID = WIDGET_BASE(/Col, Event_Pro='satview_GUI_changeAngle')
;create the sliders for the angles of the CCD's

angle3ID=CW_FSlider(tabAngID,uvalue='angle3',uname='angle3')

angle4ID=CW_FSlider(tabAngID,uvalue='angle4',uname='angle4')
;create the radio buttons for the number of CCD's
numCCDID = CW_BGROUP(tabAngID,['1','2(Default)'],$

button_uValue=[1,2],/exclusive,set_value=1,$

uvalue='numofCCDs',/no_release,/frame)


widget_control,tabAngid,/real

xmanager, 'satview_GUI_changeAngle',tabAngID

end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: is there a function or command in IDL like the "bitget" in matlab?
Next Topic: Re: is there a function or command in IDL like the "bitget" in matlab?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:27:29 PDT 2025

Total time taken to generate the page: 0.01340 seconds