Skip to main content

A custom Streamlit component to evaluate arbitrary Javascript expressions.

Project description

Streamlit-JS-Eval

PyPI version Downloads

SJE is a custom Streamlit component, built to evaluate arbitrary Javascript expressions and return the result. It can become useful in doing certain functionalities which are simple things in JavaScript, but unavailable or difficult to do in Streamlit. Examples include cookie management, writing to clipboard, getting device width (e.g. to check if we are on a mobile device), getting browser language, sharing something through Android's share feature, knowing user agent, etc. See MDN docs for more information about Web APIs.

Install

pip3 install streamlit_js_eval==0.0.13

Example

st.write(f"Screen width is {streamlit_js_eval(js_expressions='screen.width', want_output = True, key = 'SCR')}")

key is an arbitrary but unique string, required by Streamlit components API for each call to streamlit_js_eval.

Common JavaScript functionalities

Some more common functionalities are already implemented as Python functions. Examples include:

# Returns user's location after asking for permission when the user clicks the generated link with the given text
location = get_geolocation('Get my location')
# The URL parts of the page
location_json = get_page_location()

See streamlit_js_eval/__init__.py for more functions.

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_js_eval-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_js_eval-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_js_eval-0.1.0.tar.gz.

File metadata

  • Download URL: streamlit_js_eval-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for streamlit_js_eval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfbf0aef5001f3228c05fa22ac8c411081c51a918013c4d2b983b3d9c965abd1
MD5 be6b9b247d586cf1d2aefb68d57fab03
BLAKE2b-256 1cb1b65fad4e13c0ad10b59967196e20fcc34a3443d5322bd2d98dad5ba7b2f1

See more details on using hashes here.

File details

Details for the file streamlit_js_eval-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_js_eval-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bef4ed6856d2116159b0fc13545b041d6e73d78305f058befaa8f5f688a0416
MD5 fa77611247615b47bb4fbc75dff0b928
BLAKE2b-256 408d114754d7a33b53dc8bccf7c8edb332bb836a377473808786c16ea5f1163f

See more details on using hashes here.

Supported by

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