A callable: Streamlit will rerun the app and execute the callable as a callback function before the rest of the app. In this case, st.dataframe will return the selection data as a dictionary.
When it calls my function, how does the return value of st.dataframe get to my function?
I want to use the callback to display things, when I use st.write I can’t find the display anywhere. I’ve been able to successfully display things in the sidebar as per the example but that is not ideal for displaying pdfs. Any advice?
@maustin What are you trying to do specifically? The selection event information in Session State or from the dataframe command is just information in Python. You can take the information to filter out the selected row and show that information (whether that’s in the sidebar or not), or you can use that information to query some other data and show that. There’s nothing special about how you use the selected row or where you show something as a result of it.
For example, if you have a dataframe with file names and someone selects a row, you can use the returned row index to lookup up the name of the file in your original dataframe, then use the filename string to go read the file and display something from it.
ah, I see. I’m trying to display the pdf that the selected row is associated with. Right now I do that by using a callback on selection. If I’m understanding correctly though, you’re saying I could set on_click to ignore or rerun and just use the session state for the selected information. That worked perfectly! thanks
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.