Is there a way to make values of multiple sliders dependent on each other?
For example, suppose we have three sliders: x1, x2, and x3. I want:
- the value of x2 and x3 gets updated automatically when I change x1 as x2 = x1 / 2 and x3 = x1 / 2
- and the value of x1 gets updated automatically when I change x2 and x3 as x1 = x2 + x3
Item 1 is achieved easily in isolation:
x1 = st.slider("x1", 1.0, 100.0) val0 = x1 / 2 x2 = st.slider("x2", 1.0, 100.0, val0) x3 = st.slider("x3", 1.0, 100.0, val0)
But I want both to happen simultaneously. When I change x1, the values of x2 and x3 get updated and when I change x2 and x3, the value of x1 to be updated.
Is there a way to to do this?