I’m a long-time user of Rstudio-shiny and built some pretty big apps (e.g., Radiant – Business analytics using R and Shiny). I’m intrigued by streamlit and curious if something like the following is possible in this framework
User selects values for inputs in an app
Inputs are translated into python code
Code is added to an AceEditor embedded in the app, after a button click
Code can be re-run from the AceEditor
See the video below for a demo in my Radiant app of what I have in mind.
Alternatively, could an app be launched from a menu in jupyterlab or from a cell in a jupyterlab notebook cell, inputs get translated into python code, and the generated python code returned to be run in a jupyter notebook cell
Hi @Vincent_Nijs, welcome to the Streamlit community!
The glib answer is ‘sure, anything’s possible!’ I only skimmed the video, I think some combination of session state and the streamlit-ace package is probably what you need. The biggest thing is remembering what the inputs are (session state), and being able to generate the equivalent Python code for an operation (though, this could be a giant hassle).
Thanks for the comment @randyzwitch. After reading the below, my impression is that streamlit-ace could not access state from another part of a multi-page app. Is that correct?
Have you seen any (simple) examples of using a streamlit app to generate python code. The simplest way to do this might be with f-strings but I assume there are better ways to do this in python. Any suggestions welcome
The communication part is a subtle distinction…you can’t communicate on the browser side between components, as they are each sandboxed. However, bi-directional components can pass data back through Python.
So you can take what is passed in through Ace editor, evaluate it on the Python side, then write to another component the generated code. I don’t, unfortunately, have a good suggestion on how to generate that code, as I suspect f-strings would be pretty brittle.
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.