Skip to content

Why Callbacks instead of Streamlit-Like "if"-statements? #21

Closed Pinned Answered by falkoschindler
elimintz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Eli,

Our problem with Streamlit was mainly due to the way it handles user interaction. Writing if st.button('Click'): st.text('Hey!') is super cool. But it hides the underlying event loop by implicitly re-evaluating the script. That works in simple cases, but it gets quickly rather complicated to achieve apparently "normal" behavior.

State

If the script starts with loading some non-constant initial state, e.g. from an external source, this state is reset whenever the script is processed again. The following script already shows inconsistent behavior. Initializing state with a constant works, but assigning a non-constant random value overwrites the user-selected state every time.

import s…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rodja
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1 on February 19, 2022 10:08.