Possibility of interaction between Javascript and Streamlit objects

Is it possible to trigger a streamlit widget via Javascript and to share data from Javascript to python?

Here’s a simple use case for what I’m asking: I have a table with a Javascript button in each row. When I click a button, a javascript alert will show in the browser with this row’s data. Instead, I’d like to show the data in a st.write() object, for which I should be able to send the data to session_state or to a python variable or something, and I don’t know how to do that.

A more complicated but useful case would be to use the streamlit file_uploader to upload files for a specific row. Consider the JavaScript button action to change the file_uploader directory according to which row the button is being clicked, so I could control which row a file belongs or refers to.

Furthermore, as streamlit is implementing the ability to show a popup window, in the future I’d like the row button to open a popup window containing a st.write() widget showing the row data and a file_uploader widget that would change its destiny directory according to which row the javascript button was clicked on. Pretty much both solutions above combined.

Any thoughts on how to do some of that?

For anyone trying to solve the same problem, I solved it by using JS code to select the row and accessing the selected row with aggrid_table[“selected_rows”] and sending its data to the file uploader.

1 Like

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