Re: passing values to cw_fslider [message #58866] |
Thu, 21 February 2008 12:55 |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "Mark" == Mark <astroboy2k@gmail.com> writes:
> Hello. I'm trying to write a program in which changes in
> the quantity associated with one widget are reflected in
> the values of other widgets, and I am at a loss to do
> this. In fact, I'm not sure it even can be done.
> In the example below, I have slider widgets for mass,
> volume, and density. If I change the volume slider, the
> mass is held constant and a new value for the density is
> calculated. Etc.
In your example, the get and set_uvalue stuff is in the main
routine, not your event handlers. If you identify each widget
with a uname, you can use widget_info(event.top,find_by_uname='widget uname')
to find the appropriate widget, then get their values and update
as needed in your event handlers.
For example, if you define your widgets like this:
dens = cw_fslider(slide_dens,value=5.,min=0.1,max=10.,title='DENSIT Y: gm/cc', uname='density')
vol = cw_fslider(slide_vol,value=8.,min=0.1,max=10.,title='volume: cm-cubed', uname='volume')
mass = cw_fslider(slide_mass,value=40.,min=0.1,max=100.,title='mass : grams', uname='mass')
then you could rewrite pro_1 to include
widget_control, widget_info(event.top,find_by_uname='volume'), set_value=(*pinfo).mass/density
and so on for pro_2 and pro_3.
Mike
|
|
|