Skip to main content

A small package that allows you to create multi page streamlit apps

Project description

streamlit-multipage-framework

Framework for implementing multipage structure in streamlit apps. It was inspired by upraneelnihar's project: https://github.com/upraneelnihar/streamlit-multiapps.

Developed by: Yan Almeida. Improved by: ELC.

Required Libraries

  1. Streamlit (pip install streamlit);
  2. Joblib (pip install joblib);
  3. OS (pip install os).

Code Elements

Functions and Classes

  1. function initialize() -> Runs when the program starts and sets the initial page as 0;
  2. function save(var_list, name, page_names) -> Saves a list of variables, associates it with a name and defines which pages will receive these variables;
  3. function load(name) -> Loads a var_list previously saved;
  4. function clear_cache(name=None) -> Clears the variables in cache. Receives a list of variables to erase, but if none is given, clears all of the variables;
  5. function start_app() -> Clears all the variables in the cache when the app is started (but not after this);
  6. function change_page(pag) -> Sets the current page number as pag;
  7. function read_page() -> Returns current page number;
  8. class app -> Class to create pages (apps), defined by two attributes: name and func (app script defined as a function in the code);
  9. class MultiPage -> Class to create the MultiPage structure, defined by the following attributes: apps (a list containing the pages (apps)), initial_page (used to set a starting page for the app, if needed), initial_page_set (used to determine whether a starting page is set or not), next_page_button and previous_page_button (in order to define the label of the buttons that switch between pages), navbar_name (to set the navigation bar header) and block_navbar (to keep your app without a navigation bar).

MultiPage Public Attributes

  1. next_page_button -> Defines the label of the "Next Page" button. Default: "Next Page";
  2. previous_page_button -> Defines the label of the "Previous Page" button. Default: "Previous Page";
  3. start_button -> Defines the label of the starting page button that starts the application (it's only used if the app has a starting page). Default: "Let's go!";
  4. navbar_name -> Defines the Navigation Bar's name. Default: "Navigation".

MultiPage Class Methods

  1. add_app(self, name, func) -> Creates an app and adds it to the apps attribute;
  2. set_initial_page(self, func) -> Sets a starting page to the program;
  3. disable_navbar(self) -> Removes the navigation bar;
  4. run(self) -> Creates a sidebar with buttons to switch between pages and runs the apps depending on the chosen page. It also keeps the variables defined in previous pages, if the app function correctly applies "save".

How to use it

  1. Download "multipage.py" and put it in the same folder as your app;
  2. Import the class MultiPage and the functions save and start_app from multipage.py;
  3. Create a MultiPage object;
  4. Use the function start_app to clear the cache;
  5. Set the buttons' labels (next_page_button and previous_page_button attributes) and the navigation bar name (navbar_name attribute);
  6. Define the different pages (apps) as functions (use the save method in the end of each function if you need the app to remember the variables). If you do save variables, they are going to be passed as argument to the target functions;
  7. Use the add_app method to include each one of the functions;
  8. If you have a starting page for your program, include it by using the set_initial_page method;
  9. Use the run method.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-multipage-0.0.13.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

streamlit_multipage-0.0.13-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-multipage-0.0.13.tar.gz.

File metadata

  • Download URL: streamlit-multipage-0.0.13.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for streamlit-multipage-0.0.13.tar.gz
Algorithm Hash digest
SHA256 e802c882c0a4b837615768c6f9e3d930764f0ab20c515d4391c8c1786e5ea3c6
MD5 2c40050a6ce379c74f50eee7481f1d76
BLAKE2b-256 576a4f5d2fc46750353a8be363a21468da0d4b033fb5f11b6b3670af38daefb0

See more details on using hashes here.

File details

Details for the file streamlit_multipage-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: streamlit_multipage-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for streamlit_multipage-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 5480bb92258d9190a12f1ee36714ff5d37fec84d440185427e97c7e46bfc4d27
MD5 93cfff569efa2b777ddfd62f5fbab24d
BLAKE2b-256 f1dfab47c35e80a0ecba21014cef02ee3be791e1d99d54938faf226e92f21ad3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page