St.button to initiate python file the way streamlit run then python file works in command prompt

Summary

I have a python code where I want to create a st.button to be clicked and once it is the python code I have for the app initiates and runs in its entirety. Eventually I want to create multiple buttons on the same page that initiate different python files. I just don’t know how to write the st.button function to initiate the code.

Steps to reproduce

Code snippet:

import streamlit as st
with header:
	st.title('Welcome to my FreeWeibo Dataset')
st.button(POS.py)

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:
What I want to happen is I will create a so called master app that shows the above text which will be my “homepage” and once the user clicks the button it runs the code from a python file. I currently have the python file run as a different streamlit app but I am trying to create an app that has 3 buttons that run three different python files.

Explain what you expect to happen when you run the code above.

Actual behavior:

Nothing happens at the moment since I do not have the correct syntax.

Debug info

  • Streamlit version: 1.15.1
  • Python version: 3.9.15
  • Using Conda
  • OS version: Windows 10
  • Browser version: Chrome

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

You’ll need to use session state and callback functions.

import streamlit as st

def do_something():
    # perform a task
    # modify or add to session state

st.button('Just do it!', on_click=do_something)

if st.session_state.some_key:
    # conditional display based on some flag or data in session state
    # --could be a key to register the button was clicked if you want the click 
    #   to be remembered longer term
    # --or could be actual data stored in session state that you check

ok so the code would be

import streamlit as st
with header:
	st.title('Welcome to my FreeWeibo Dataset')
st.button('Part of Speech'), on_click=do_something)

if 'key' not in st.session_state:
        st.session_session['key'] = "First part of my code?"

Not quite. There’s a typo and missing info. Can you describe a little bit more about what kind of process you want to happen with the button click? I can be a little more specific in the example then.