This small app try to demo a application framework for streamlit.
- Separate the layout and logic.
- Use application states to control the layout since Streamlit will run the code repeatedly.
working_step
is used
class Env
: used to access global variables st.session_state, make access the variable more readableclass Show
: manage all layoutclass App
: implement all business logic
-
through global variables, Env
-
use instance, app in Show and show in App, which will combine two classes
- direct access variable in eather class, or
- use method call to encapsulate the detail
we use 2nd method in the demo code.
- The "default way" Streamlit use to connect input widgets to st.session_state via "keywords" is a BAD concept. Hided in another global session variable and pass to on_change args is better.