Displaying buttons on sidebar and Input Text box on Main window

Hi All,

I have a question if i want to display 5 buttons on the sidebar and a upload Dataset button on the Sidebar and Input Text box on main window , and for example once user clicks on Button1 on the sidebar , it analyzes the sentiment for the text entered by the user in Input Text box on Main window and displays the sentiment in the main window, how to do that, Please refer some sample code for the same.

Please Advice.

You can do it of course. Just be careful about the order of code in your main code.

sideb = st.sidebar
check1 = sideb.button("Check or not?")
textbyuser = st.text_input("Enter some text")
if check1:
    st.info("Code is analyzing your text.")
    #Your code to analyze the sentiment that only works when the button is clicked.

1 Like