Slider Button API?


Consider the following code:

powerMin = Draw.Slider( 'Power Min: ', EVENT_SLIDER_POWER_MIN, X_MARGIN, lines[1], SLIDER_WIDTH, SLIDER_HEIGHT, powerMin.val, AudioAnalysis.POWER_MIN, AudioAnalysis.POWER_MAX, 1, 'Minimum power amplitude data point.' )

The slider’s value can be changed by setting powerMin.val.

Now how do you change the minimum and maximum values for the slider? I’d like to do something similar to the following (which does not work):

powerMin.min = 5
powerMin.max = 105
powerMin.val = 5

If recreating a new Slider is the only option, how is the old one removed?

I have also tried to reset the initial value and limit values using:

powerMin.val = (5, 0, 100)

Also does not work. I have started using Python’s introspection to get at the guts of the object, but I either see [] or function API documentation. Sadly, I see nothing about the internal representation of the Button …

As far as I know, the button min and max have to be set at creation. The only attribute that is publicly accessible after creation is val, I believe (or that is what the basic API docs incenuate).

You could, however, just delete the button and remake it in the same place, and reapply names and atributes. It’ll take a little more memory and processor power, but it could with some tweaks to achieve it.

Hi, forTe.

Thanks for the reply!

Do you know how to delete the button? I see nothing in the API that says “delete”, “remove”, “vaporise”, “demolish”, “destroy”, or even “hide”.


I don’t know your full setup, so I may be a bit off, but the powerMin button assignment should be inside the main drawing function. Then, all you would have to do would be to change the AudioAnalysis.POWER_MIN and AudioAnalysis.POWER_MAX, and the slider would update appropriately.


Here’s some quick code to show how to do it. I suppose delete wasn’t really the right word. It just requires I redraw.

import Blender
from Blender import Draw, BGL

chslide = Draw.Create(0.0)
min = Draw.Create(-2.0)
max = Draw.Create(2.0)

def gui():
    global chslide, min, max
    chslide = Draw.Slider("Slide: ", 3, 200, 300, 200, 19, chslide.val, min.val, max.val, 1, "Change it")
    min = Draw.Slider("Min: ", 2, 150, 200, 150, 19, min.val, -20, 0, 1, "Min Value")
    max = Draw.Slider("Max: ", 2, 300, 200, 150, 19, max.val, 0, 20, 1, "Max Value")
    Draw.PushButton("Quit", 1, 10, 10, 50, 19, "")
def bevent(evt):
    if evt == 3:
    elif evt == 1:
    elif evt == 2:
def event(evt,val):
    if evt == Draw.ESCKEY:

Draw.Register(gui, event, bevent)

Sorry, its not the most elegant or organized code ever written, but it does allow you to change the limits.

Hi, folks.

Of course, this makes perfect sense. I shall try it immediately.

Thank you!