The problem of not using the return value of the function inside the other function in Streamlit, Python

#Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
import fitz 
import io
import streamlit as st

global path_input_0    #HERE ASSIGNMENTS-------------------------------
path_input_0=""
path_input_last=""

def login():
  
    # interface codes for the login screen
    path_input_0 =st.text_input("File Path:", "Please enter the path to the folder containing the Abstract_Account_Web_App.py file")
    st.write(path_input_0)
    global proceed
    if st.button("Proceed"):
        st.session_state["page"] = "main"
        st.balloons()
        st.experimental_rerun()
    return path_input_0


def main():
    # interface codes for the main screen
    
    pathz=path_input_last+"/Bankomat Alışveriş Özeti.pdf"
    st.write("path1:",pathz)
    file_names = [r'%s' % pathz]
    st.write(file_names)



        

    
if __name__=='__main__':
               
    if "page" not in st.session_state:
                  st.session_state["page"] = "login"
    
    if st.session_state["page"] == "login":
                 
                  path_input_last=login()
                  st.write("last:",path_input_last)
                  
     
    elif st.session_state["page"] == "main":
                  st.balloons()
                  main()

Hello friends, I’m trying to take the path from the login screen and use it on the main screen. The login function returns the path_input_0 from the user. But I can’t get this output and use it in the main function Pathz=path_input_last+“/Bankomat Alışveriş Özeti.pdf”. Main function’s path_input_last comes as null.(“”) So it just prints path1 as /Bankomat Alışveriş Özeti.pdf. I don’t want that. The full file path is not coming. How Can I solve this problem? Could you explain the solution?
The second interface visual (first login screen and then main screen):
streamlit-main

You can make it a global variable.
Or pass it through session state…

@alonsh Could you explain a little more specificly?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.