Modal text input component

Hello,

For those interested, I’ve designed a ‘modal’ text input widget.

‘modal’ meaning that the python script actually pauses until the widget returns an output string.

You can thus do things like:

txt=modal_input("Enter text here")
#waits until txt is returned from the front-end
st.write(txt)
#prints the input text immediately without needing a rerun

This is made possible by leveraging firestore as a direct means of communication between backend and frontend. (You need a firebase account and a firestore database setup to use it)

More info in the repo.

Using firestore is quite an arbitrary design choice, as you could use any other instant messaging service API to achieve the same result. Just fork the repo and adapt the logic to your specific needs, but it gives a working starting point.

Enjoy!

Baptiste

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