Narasimha Baliga
Narasimha Baliga

Reputation: 11

Streamlit: Session_state() and Multiapp() - Navigation

I wanted a layout where a user enters a file in "home page", and can perform visualization etc and again go back home add file to existing selected file.

Currently, when I go back home the selected file doesn't exists. Is there a way, where the file selected remains, while I navigation to other tab and come back home?

Upvotes: 1

Views: 3020

Answers (1)

Ailurophile
Ailurophile

Reputation: 3005

There is a workaround for using sessionstate for multipage functionality, which can be found in the discussion here - Multi-page app with session state.

These are some useful gists

stateful_streamlit_enterprise

An example of how one can track state between multiple pages in Streamlit without reloading pages.

In addition to this, it also demonstrates Mypy type-safety with classes, decorators, inheritance, wrapping Streamlit, etc.

Instead of using self, you'll find that all data lives in the session sess.

Tested on Python 3.7 and Streamlit 0.73.

Upvotes: 1

Related Questions