Py.Cafe

fomightez/

draft-solara-slider

drafting slider in Solara towards trying to make guessing game in it

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# based on https://solara.dev/documentation/components/input/slider
# but I added settng initial value to an integer instead of 
# hardcoding `42` in two places.
import solara

initial_num = 42

int_value = solara.reactive(initial_num)


@solara.component
def Page():
    solara.SliderInt("Some integer", value=int_value, min=-10, max=120)
    solara.Markdown(f"**Int value**: {int_value.value}")
    with solara.Row():
        solara.Button("Reset", on_click=lambda: int_value.set(initial_num))