Skip to content

Range slider

Picks a range such as a price from 20 to 80. value is (low, high) and on_change receives the new pair. Pressing the track moves the nearer knob there and dragging keeps moving it; the knobs never cross.

ui.range_slider · Category: Forms · Full reference →

Range sliderRange slider
  • To filter by a range: prices, dates, sizes, years.
  • For a single number, use Slider.
import pyzed as pz
from pyzed import ui
class Shop(pz.App):
def __init__(self):
self.price = (20, 80)
def view(self):
return ui.range_slider(self.price, lambda value: setattr(self, "price", value),
min=0, max=500, step=5, show_value="{:.0f} €")
Range slider: PlainRange slider: Plain
Plain
Code
pz.container(ui.range_slider((0.2, 0.7), on_change), width=320)
Range slider: show_value=TrueRange slider: show_value=True
show_value=True
Code
pz.container(ui.range_slider((10, 60), on_change, min=0, max=100, step=1, show_value=True), width=360)
Range slider: show_value="{:.0f} €"Range slider: show_value="{:.0f} €"
show_value="{:.0f} €"
Code
pz.container(ui.range_slider((50, 250), on_change, min=0, max=500, step=10, show_value="{:.0f} €"), width=380)
Range slider: tint="success"Range slider: tint="success"
tint="success"
Code
pz.container(ui.range_slider((30, 90), on_change, min=0, max=100, tint="success"), width=320)
Range slider: disabled=TrueRange slider: disabled=True
disabled=True
Code
pz.container(ui.range_slider((20, 80), on_change, min=0, max=100, disabled=True), width=320)

Range slider has 2 events of its own, listed below. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

Event Handler gets When
on_change ((low, high)) Callable that receives the new (low, high).
on_release () Sent when the knob is let go (save or apply there).

Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().

The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.

class Shop(pz.App):
def __init__(self):
self.price = (20, 80)
def set_price(self, value): # on_change: the new (low, high)
self.price = value
def search(self): # on_release: the knob was let go
print("search", self.price)
def view(self):
return ui.range_slider(self.price, self.set_price, min=0, max=100, step=5,
on_release=self.search, show_value=True)
range_slider(
value,
on_change=None,
*,
min=0.0,
max=1.0,
step=0.01,
min_gap=0.0,
on_release=None,
width='fill',
tint='accent',
disabled=False,
show_value=False,
theme=None,
)

A slider with two knobs that picks a range. Pressing the track moves the nearer knob there and dragging keeps moving it; the knobs never cross.

Property Default Description
value required (low, high).
min 0.0 Smallest value.
max 1.0 Largest value.
step 0.01 Values snap to multiples of this.
min_gap 0.0 Smallest distance kept between both knobs.
width "fill" Width: pixels, "fill", "shrink" or "fill:N" (proportion).
tint "accent" Color of the range between the knobs.
disabled False Disables it (ignores clicks).
show_value False Adds low – high next to it: True, or a format for each end such as "{:.0f} €".
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_change, on_release (events).

Full reference →