float / log - slider, deriving from wx.Slider ?

I have my own implementation of a floating point slider, which I am attaching. It's not derived from wx.Slider and looks somewhat different. It's intended to resemble a scroll bar with a thumb, a background bar and two "vernier" up and down buttons. You change the value by either:
(1) Clicking on the vernier buttons (very small change)
(2) Dragging the thumb (bigger change)
(3) Clicking on the bar background (big jumps)
(4) Right clicking to bring up a text window where you can type a new value.

It's threadsafe (you can change the value programmatically unless the user is in the act of changing it).

In the same file is a bar graph to display a numerical value that the user cannot change, and the two classes share a common layout. If you execute this file there is a crude demo of the two kinds of controls; the bar graph will display the slider's value.

Both classes use a class in a second file called "tickopt.py" that intelligently changes the scale when the control is resized horizontally.

These two files live in a package named pac.ui ('pac' is my initials), so in order to run bar2.py you may have to edit the line in bar2.py that imports the tick optimizer.

This code addresses the problems you mention, such as positioning the labels, scaling the slider position, formatting the labels, etc. These are non-trivial problems to solve in general.

Paul Cornelius

Stef Mientki wrote:

tickopt.py (3.17 KB)

bar2.py (30.5 KB)

ยทยทยท

hello,

I'm trying to create a float / log slider,
by deriving from wx.Slider.

The basics works but I've a view details (?) I didn't solve yet,
you can see the problems in the attached example:

- how to position the labels, as you can see it the demo, the y-coordinates are wrong
(should I take over the SetPosition event )

- how to return the right size, because now it returns the height excluding the labels
(one solution might be to know that the slider is 24 pixels in height,
add the vertical size of the labels and take over the GetSize event,
but it sounds very complicated to me :wink:

- how to determine the width of a formatted floating point number (something with 'extent' ?)

- how to print a nice floating point number (but I already posted that in the SciPy group)

thanks,
Stef

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org