Spaces:
Runtime error
Runtime error
File size: 1,092 Bytes
642c876 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os
import streamlit.components.v1 as components
from typing import Tuple
# Now the React interface only accepts an array of 1 or 2 elements.
_component_func = components.declare_component(
"custom_slider",
url="http://localhost:3001",
)
# Edit arguments sent and result received from React component, so the initial input is converted to an array and returned value extracted from the component
def st_custom_slider(label: str, min_value: int, max_value: int, value: int = 0, key=None) -> int:
component_value = _component_func(label=label, minValue=min_value, maxValue=max_value, initialValue=[value], key=key, default=[value])
return component_value[0]
# Define a new public method which takes as input a tuple of numbers to define a range slider, and returns back a tuple.
def st_range_slider(label: str, min_value: int, max_value: int, value: Tuple[int, int], key=None) -> Tuple[int, int]:
component_value = _component_func(label=label, minValue=min_value, maxValue=max_value, initialValue=value, key=key, default=value)
return tuple(component_value) |