I ran a st.write(max_num_weibos) and I get an output so its definitely not 0
Ah! It just occurred to me how this is happening.
This input widget is being generated in a function that is a callback (your button click). When a widget is changed, it creates a rerun. Hence you have a rerun within a callback.
Instead of the two buttons on your homepage, just make them separate pages in your app.
- Remove the buttons from POS.py
- Create a pages folder beside POS.py
- Create two simple files inside the pages folder
a. Simply import and run the script you were previously running as a callback, one page for each button
(Note that for the sake of relative directories, your couple of one-line files should have the same relative paths you used inside POS.py because Streamlit will run in the same directory as your main app POS.py even for the scripts in your pages folder.)
what do you mean by create a new page how would I do that?
Exactly as I mentioned above. Page creation (and the resultant sidebar navigation) is all automatic. Just name a folder pages
, stick it in the same directory where your main app (POS.py
) lives, and any_file.py
that you put in the pages folder becomes a new page in your Streamlit app.
When you run streamlit run POS.py
, it will magically have a new page available in the sidebar, one for .py file you put in the pages folder.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.