Unable to bring up main application screen after streamlit welcome screen seperately

proceed=0
def login():
#interface codes for the login screen   
 global proceed
    if st.button('Proceed'):
         proceed=1
         st.balloons()
         if proceed==1:
            main()
def main():
#interface codes for the main screen 

if __name__=='__main__' :
                    
               login()

Hello friends, I have prepared two interface codes, the login screen, and the main screen. When I press the proceed button on the login screen, I want the login interface to disappear and only the main interface to appear.
When you press the proceed button in the current state of the code, both interfaces appear on one screen. I want only the main screen to appear when I press the proceed button. How can I solve this problem?
Could we use show hide: none css property for the login screen?
The login screen :

Hi @murat_tasci,

Here’s one way to accomplish this, using st.session_state to keep track of which page you’re trying to show

import streamlit as st


def login():
    # interface codes for the login screen
    st.write("Welcome to the login screen")
    global proceed
    if st.button("Proceed"):
        st.session_state["page"] = "main"
        st.balloons()
        st.experimental_rerun()


def main():
    # interface codes for the main screen
    st.write("Welcome to the main screen")


if "page" not in st.session_state:
    st.session_state["page"] = "login"

if st.session_state["page"] == "login":
    login()
elif st.session_state["page"] == "main":
    main()

You might also consider making this a multipage app Introducing multipage apps! 📄

1 Like