Hi @po_hi,
thanks a lot for posting to the forum. st.button
will return true
If the button was clicked on the last run of the app.
(From our doc)
On top of this pressing the button will trigger a re-run. Does this explain the behavior you are seeing with the code snipped you posted? Feel free to post a feature request here
As for auto-refreshing a chart, if you want to poll periodically a data source, you need programmatic re-runs. We are developing this feature and it is tracked here: Request: st.stop() · Issue #168 · streamlit/streamlit · GitHub. You will also need Session State to persist data across re-runs. We are also working on Session State. This topic has a more thorough discussion on it.
This gist, for example, uses programmatic reruns along with Session State to implement a dashboard. You can just try it out by downloading the Session State and reruns gists linked in the gist above.
Best,
Matteo