Hi @jorick!
- How can I modify the value of the slider widget?
I’m having trouble understanding what exactly you’re trying to build. Can you post a mockup?
Answering your question as best I can without the mockup, I think what you’re looking for is support for “session state”. We have a session state feature request here, and a prototype implementation here.
This is how your code would look with the prototype implementation:
import streamlit as st
# SessionState module from https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92
import SessionState
state = SessionState.get(position=0)
# The slider needs to come after the button, to make sure the first increment
# works correctly. So we create a placeholder for it here first, and fill it in
# later.
widget = st.empty()
if st.button('Increment position'):
state.position += 1
state.position = widget.slider('Position', 0, 100, state.position)
- How can I clear the button push after it has been pushed?
Buttons get cleared automatically next time the script runs. So if you have x = st.button("Click me!")
, then:
- The first time your app runs,
x
isFalse
. - When you interact with any other widget in your app,
x
isFalse
- When you click the button,
x
isTrue
. - Next time you interact with any other widget in your app,
x
isFalse
again