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.
Required Libraries
- Streamlit (
pip install streamlit
); - Joblib (
pip install joblib
); - OS (
pip install os
).
Code Elements
Functions and Classes
- function
initialize()
-> Runs when the program starts and sets the initial page as 0; - 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; - function
load(name)
-> Loads a var_list previously saved; - 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; - function
start_app()
-> Clears all the variables in the cache when the app is started (but not after this); - function
change_page(pag)
-> Sets the current page number aspag
; - function
read_page()
-> Returns current page number; - class
app
-> Class to create pages (apps), defined by two attributes: name and func (app script defined as a function in the code); - 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
next_page_button
-> Defines the label of the "Next Page" button. Default: "Next Page";previous_page_button
-> Defines the label of the "Previous Page" button. Default: "Previous Page";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!";navbar_name
-> Defines the Navigation Bar's name. Default: "Navigation".
MultiPage Class Methods
add_app(self, name, func)
-> Creates an app and adds it to theapps
attribute;set_initial_page(self, func)
-> Sets a starting page to the program;disable_navbar(self)
-> Removes the navigation bar;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
- Download "multipage.py" and put it in the same folder as your app;
- Import the class
MultiPage
and the functionssave
andstart_app
from multipage.py; - Create a
MultiPage
object; - Use the function
start_app
to clear the cache; - Set the buttons' labels (next_page_button and previous_page_button attributes) and the navigation bar name (navbar_name attribute);
- 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; - Use the
add_app
method to include each one of the functions; - If you have a starting page for your program, include it by using the
set_initial_page
method; - Use the
run
method.
Project details
Release history Release notifications | RSS feed
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.7.tar.gz
(16.7 kB
view details)
Built Distribution
File details
Details for the file streamlit-multipage-0.0.7.tar.gz
.
File metadata
- Download URL: streamlit-multipage-0.0.7.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c177adcf101a7cc4a747390f10c202a8b38e58d1752c9f9160df5b3d7694fdf |
|
MD5 | b6188a49275585944ec1a501868a57c1 |
|
BLAKE2b-256 | 3ba87c652deb730aab36709be875e364d7c21de01f8ff7614061fb6c24299a0d |
File details
Details for the file streamlit_multipage-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: streamlit_multipage-0.0.7-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590675f28c1aafdd387925bdf58fb2115cac9c6e0825c3d2395282f71a8323df |
|
MD5 | 1069642695b5efe27f77101e6323b77e |
|
BLAKE2b-256 | c0ab0b954916d51afd5b9663ddfadf086c23c5da22e28d909729e293216c5c79 |