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

Home » Public Forums » archive » Re: widget_slider with odd integers
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: widget_slider with odd integers [message #31515] Mon, 22 July 2002 12:41
Daniel Peduzzi is currently offline  Daniel Peduzzi
Messages: 29
Registered: June 1999
Junior Member
Thierry Savin wrote in message <3D3C4643.1080709@mit.edu>...
> Hi all,
>
>
> Does anyone know how I could create a slider widget that produces only
> odd integers ?
>


If you are on a UNIX system, you could create a slider like this:

sliderID = widget_slider(base, value=some_odd_value, /drag, event_pro='slider_event')

which will cause the "slider_event" callback to be invoked whenever the
slider is dragged.

Then in your callback:

pro slider_event, event
my_odd_value= event.value / 2 * 2 + 1
widget_control, event.id, set_value=my_odd_value
return
end


This doesn't work *quite* as nicely under Windows, since drag events are
not generated...but the value will still jump to an odd value when the
thumbnail is "dropped."

Note: be careful of the maximum slider value (for example, trying to set
a slider with a max of 100 to the value 101 will result in a value of 100.)

Dan

---------------------------------------
Daniel C. Peduzzi
peduzzi@attbi.com
---------------------------------------
Re: widget_slider with odd integers [message #31517 is a reply to message #31515] Mon, 22 July 2002 11:46 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 22 Jul 2002 10:52:03 -0700, Thierry Savin wrote:

> Hi all,
>
>
> Does anyone know how I could create a slider widget that produces only
> odd integers ?
>

Use /SUPPRESS_VALUE, and compute in your event callback:

my_odd_value=2*ev.value+1

for use as the real value for display in a suitably located widget_label,
and for whatever data context you intend. You can of course extend this
same method to do all manner of interesting things, like create floating
sliders (though many already exist in libraries), or non-linear sliders.

Good luck,

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: unwanted color bands in image display
Next Topic: Linking multiple files...

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

Current Time: Wed Oct 08 13:45:32 PDT 2025

Total time taken to generate the page: 0.00494 seconds