ui_slider
result = ui_slider(label, min, max, [default], [step=], [id=])
Input: label, min, max, default, step, id · Output: result
What it is
Declares a slider control (for a value you sweep) in an explore page or Qu Studio, labeled label (string) with range min..max (numbers). default (number, positional, default min) is the starting value; step= (number) sets the increment; id= (string, default label) is the identifier the host uses to persist/report a value, useful when two sliders would otherwise share a label. Outside a host, returns the current (or default) value as a number — arguments are positional, not steps=-style keywords, and min/max (not from/to) are the names that matter.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = ui_slider(label, min, max, [default], [step=], [id=]) | label string or numberDeclares a slider control (for a value you sweep) in an explore page or Qu Studio, labeled label (string) with range min..max (numbers).min string or numberDeclares a slider control (for a value you sweep) in an explore page or Qu Studio, labeled label (string) with range min..max (numbers).max string or numberDeclares a slider control (for a value you sweep) in an explore page or Qu Studio, labeled label (string) with range min..max (numbers).default number, optionaldefault (number, positional, default min) is the starting value.step number, optionalstep= (number) sets the increment.id string, optionalid= (string, default label) is the identifier the host uses to persist/report a value, useful when two sliders would otherwise share a label. | result scalar or Num | Returns a scalar Num — the host's current value for this control, or default outside one. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
freq = ui_slider("freq", 1, 20, 5)
gain = ui_number("gain", 1.0)
mode = ui_select("mode", ["fast", "slow"])
enabled = ui_checkbox("enabled", true)
pressed = ui_button("reset")
label = ui_text("label", "wave")
print(freq)
print(gain)
print(mode)
print(enabled)
print(pressed)
print(label)
5 1 fast true false wave
from plotting
How it works
Each of these DECLARES a control and returns its current value in one call, so a script reads like straight-line code (freq = ui_slider("freq", 1, 10)) rather than wiring up callbacks. With no host supplying values -- a bare qu run, or the very first run before anything's been touched -- every one returns its own default, so the same script is still a perfectly ordinary runnable script. That property is what makes these safe to put in demos. ui_slider(label, min, max, [default], [step=], [id=])
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.