Streamlit component that allows you to run js code with both blocking and non-blocking modes.
Project description
streamlit-js
Streamlit component that allows you to run JS code with both blocking and non-blocking modes.
The package is based on the streamlit-javascript.
The main difference is that the package above doesn't allow distinguishing if the JS code is executed or not in all situations (e.g. when the code returns null
).
It's important because Streamlit components works in asyncronous mode and cannot return value immediately. They need several reruns to get the value. So, it's important to know when the code is finished and when it's not.
This package solves this issue by returning []
when the code is not finished and [None]
when the code is finished and returns null
. Also, it allows to block the script until the JS code is executed and app is refreshed.
Installation instructions
pip install streamlit-js
Usage instructions
import streamlit as st
from streamlit_js import st_js, st_js_blocking
value = st_js(code='return null;')
if not value:
st.write('Loading...')
st.stop()
st.write(value) # [None]
st.write(value[0] # None
# This will block the script until the js code is executed
value = st_js_blocking(code='return null;')
st.write(value) # None
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
Built Distribution
File details
Details for the file streamlit-js-1.0.8.tar.gz
.
File metadata
- Download URL: streamlit-js-1.0.8.tar.gz
- Upload date:
- Size: 507.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f23c1c9ff1a1ca44222a2b24cd6edf84daf6e78f5bbe07dfc87b35f7e7a16526 |
|
MD5 | 78422acfb5939c5a12040dfa173fc9c9 |
|
BLAKE2b-256 | 0877e84aa98cf29572ebc49873b3d6646e4572b9f9f392cbf8b10812ee0c7264 |
File details
Details for the file streamlit_js-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: streamlit_js-1.0.8-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05d8447caa87abb123137f62e7e5aeed8ca83015ee170aa829280c7034a23117 |
|
MD5 | d55dea2f6bf275c934d94b21b04577a6 |
|
BLAKE2b-256 | d75c65614b858d39c28a1b0ed1690b73da4f6f061fca1d25e757bf56f3226f5b |