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

Home » Public Forums » archive » Re: AGAIN: Help: Retrieve the state of radio button
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
Re: AGAIN: Help: Retrieve the state of radio button [message #15097] Wed, 21 April 1999 00:00
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
I personally never use CW_BGROUP because it is cumbersome to check the
state of all buttons, do "where" every time etc. I agree that the way Tri
shown is better (I use no GUI Builder and manually code in all the
buttons):

> w = widget_base(...., /NONEXCLUSIVE) ; for group of non-exclusive
> buttons
> b1 = widget_button(w,....)
> b2 = widget_button(w,....)

In the above case I use the following style of coding:

To set up a set of buttons:

cb_base = widget_base(main_base, /nonexcl, /column, uvalue=0L)
cb_0 = widget_button(cb_base, value='Name 1', uval=0)
cb_1 = widget_button(cb_base, value='Name 2', uval=1)
cb_2 = widget_button(cb_base, value='Name 3', uval=2)
cb_3 = widget_button(cb_base, value='Name 4', uval=3) ;Continue if desired.

State = {cb_base:cb_base}
;pass state over to event handling procedure
widget_control, main_base, set_uvalue=State

To remember the state of buttons:

pro Your_pro_event, ev
widget_control, ev.top, get_uvalue=State
widget_control, ev.id, get_uval=Sender
case Sender of
0: Temp = hc_checkbutton(State.cb_base, sender, ev.select, /WID)
1: Temp = hc_checkbutton(State.cb_base, sender, ev.select, /WID)
2: Temp = hc_checkbutton(State.cb_base, sender, ev.select, /WID)
3: Temp = hc_checkbutton(State.cb_base, sender, ev.select, /WID) ;Continue
if desired.
endcase

Then, in any other part of the code that needs to check on the state of,
say, Button #0, I do:

if hc_checkbutton(State.cb_base, 0, /GET) then ... action for set button
... else $
...... action for not set button .....

Certainly, use of first child to store State is more traditional and
appropriate, here I put State in the top level base UVALUE for simplicity.

Notice that using UVALUE is not mandatory. Any integer or longword
variable can be used to store button states. hc_checkbox accepts /RETURN
and /VAR keywords to work on variables and structure fields that are passed
as values. Code for hc_checkbox is very simple and is available at
http://spot.colorado.edu/~romashki/idl/hc_checkbox.pro

I hope this helps.

Cheers,
Pavel
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Student Version won't launch
Next Topic: AGAIN: Help: Retrieve the state of radio button

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

Current Time: Thu Oct 09 07:53:31 PDT 2025

Total time taken to generate the page: 0.79927 seconds