Skip to main content

Modal text input component for Streamlit

Project description

streamlit-modal-input

Streamlit component providing a 'modal' text input widget (actually pausing the script until a string is entered and returned). Implemented using firestore for direct communication between backend and frontend.

Installation instructions

pip install streamlit-modal-input

Usage instructions

text=modal_input(
    prompt,
    firebase_credentials=None,
    firebase_config=None
)

Starts a firestore listener watching for changes in a specific firestore document. Renders a text input widget, whose output is routed to this firestore document. Waits until the listener receives the output string. Gets the string, closes the listener, deletes the firebase document. Returns the string.

The python script will thus wait for the string to be received, achieving a similar behavior as regular python input function.

You first need to set up a firebase account and a firestore database for using this.

If you don't provide your firebase credentials and config directly to the component, it will attempt to get them from st.secrets (keys: firebase_credentials and firebase_config).

In such case your secrets.toml file should have these entries :

[firebase_credentials]
type=...
project_id=...
private_key_id=...
private_key=...
client_email=...
client_id=...
auth_uri=...
token_uri=...
auth_provider_x509_cert_url=...
client_x509_cert_url=...
universe_domain=...

[firebase_config]
apiKey=...
authDomain=...
projectId=...
storageBucket=...
messagingSenderId=...
appId=...
measurementId=...

Example

import streamlit as st
from streamlit_modal_input import modal_input

my_firebase_creds={
    ...
}

my_firebase_config={
    ...
}

text=modal_input(
    "Enter text here",
    firebase_credentials=my_firebase_creds,
    firebase_config=my_firebase_config
)

st.write(text)

#Or, assuming you provided yours credentials and config in st.secrets

text=modal_input("Enter text here")

st.write(text)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_modal_input-0.0.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

streamlit_modal_input-0.0.5-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_modal_input-0.0.5.tar.gz.

File metadata

  • Download URL: streamlit_modal_input-0.0.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for streamlit_modal_input-0.0.5.tar.gz
Algorithm Hash digest
SHA256 766f6acaeef928712508ba46abbf7c11b2de1427321226f88e8f1f334350a961
MD5 a57e326ea19a52ba0915980ceb80a7c5
BLAKE2b-256 88731fcb7494286a9791e12e4e0933803269a91af74ebe6e302f0242596e9952

See more details on using hashes here.

File details

Details for the file streamlit_modal_input-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_modal_input-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6c47baf8175c76c1a38e18cb7734cb50f1820c06a334d92c4e3abd4abc0ba278
MD5 03910932bedc84c80870f370447f9f0e
BLAKE2b-256 edc481ead9df3b83d6879ea9f2cee92f7d632e3f2862e651f700cec8f5c8f3d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page