Skip to content

Instantly share code, notes, and snippets.

@ljmartin
Created September 15, 2020 10:52
Show Gist options
  • Select an option

  • Save ljmartin/d4e66084baf052de17780cdd0793c5f6 to your computer and use it in GitHub Desktop.

Select an option

Save ljmartin/d4e66084baf052de17780cdd0793c5f6 to your computer and use it in GitHub Desktop.
import SessionState
import streamlit as st
st.beta_set_page_config(
page_icon=":shark:",
layout="wide",
)
sesh = SessionState.get(curr_page = 0)
def pageZero():
st.title('This is page zero! welcome')
st.write('some text for zeroth page. Welcome to the app. Follow the nav buttons above to move forward and backwards one page')
def pageOne():
st.title('page ONE')
st.write('two')
def pageTwo():
st.title('TWO')
st.write('three')
sesh = SessionState.get(curr_page = 0)
PAGES = [pageZero, pageOne, pageTwo]
def main():
####SIDEBAR STUFF
st.sidebar.title("this is an app:")
st.sidebar.markdown('Note that as you press Next page, the page numbers go `0, 1, 3!`')
#####MAIN PAGE NAV BAR:
st.title('Navigation')
st.markdown('Click Next to go to the next page')
if st.button('Back:'):
sesh.curr_page = max(0, sesh.curr_page-1)
if st.button('Next page:'):
sesh.curr_page+= min(len(PAGES), sesh.curr_page+1)
st.markdown('----------------------------------')
#####MAIN PAGE APP:
st.write('PAGE NUMBER:', sesh.curr_page)
PAGES[sesh.curr_page]()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment