Skip to main content

streamlit-screen-stats

Streamlit component that allows you to do get various stats for your screeen to build repsonsive apps for your users with different devices.

Installation instructions

pip install streamlit-screen-stats

Usage instructions

import streamlit as st
from st_screen_stats import ScreenData, StreamlitNativeWidgetScreen, WindowQuerySize, WindowQueryHelper

# using react component
screenD = ScreenData(setTimeout=1000)
screen_d = screenD.st_screen_data()
st.write(screen_d)

## You can now use the on_change parameter on all class methods of this package. 
def onScreenSizeChange(variable):
    ## do something when the screen size has changed.
    #example
    print(variable)
    
screen_stats_result = screenD.st_screen_data(key="screen_stats_", on_change=onScreenSizeChange("this works")) 
st.write(st.session_state["screen_stats_"]) 

# using sctreamlit native widget and some custom components
# Requirements:
#  Need to install from pypi:
#    - streamlit-browser-session-storage (pip install streamlit-browser-session-storage)
#    - streamlit-local-storage (pip install streamlit-local-storage)
screenDN = StreamlitNativeWidgetScreen(setTimeout=1000) 
screen_stats_window = screenDN.get_window_screen_stats()
st.write(screen_stats_window)

# Query window screen like you would when using CSS @media () {}
# Returns dictionary result `{'status':True}` if conditions are met else `{'status':False}` if conditions are not met.
window_width_query_raw = WindowQuerySize()
window_width_res = window_width_query_raw.mediaQuery(mediaMatchQ="(max-width: 700px)") # returns dictionary result {'status':True} if window screen width is lower than 700px else {'status':False} if window screen width is greater than 700px
st.write(window_width_res)


# Query window screen helper - simplifies the above (CSS @media () {}) method
helper_screen_stats = WindowQueryHelper()
max_width_window = helper_screen_stats.maximum_window_size(max_width=800, key="window_1")
st.write("max_width",max_width_window)
min_width_window = helper_screen_stats.minimum_window_size(min_width=800, key="window_2")
st.write("min_width",min_width_window) 

window_range = helper_screen_stats.window_range_width(min_width=1000, max_width=1100)
st.write("range", window_range) 

## You can now use the on_change parameter. 
# Example:

def onScreenSizeChange(value):
    
    print(value)

large_screen_size_ = helper_screen_stats.window_range_width(min_width=1000, max_width=1100, on_change=onScreenSizeChange(value) key="lg_screen")

if large_screen_size_["status"] or st.session_state["lg_screen"]["status"]:
    st.write("rest of code here")

Metadata

Release files for streamlit-screen-stats 0.0.82

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-screen-stats 0.0.82
File Size Uploaded Provenance
streamlit_screen_stats-0.0.82.tar.gz 1.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-screen-stats 0.0.82
File Interpreter ABI Platform
streamlit_screen_stats-0.0.82-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / streamlit_screen_stats-0.0.82.tar.gz

Download URL streamlit_screen_stats-0.0.82.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
4afffabab17f6e10f91c944ab4edbc8c53b3d6319f13b77c19b8210b76b963d7
BLAKE2b-256 checksum
How to use checksums
a9349ade81306ed555c7acc84335604b60e12580a747f185012b565813d8568f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / streamlit_screen_stats-0.0.82-py3-none-any.whl

Download URL streamlit_screen_stats-0.0.82-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
040262a635bd6c4d342618c5110b7c93f186be61bc90717501282fe95cdc0075
BLAKE2b-256 checksum
How to use checksums
665342d8fbeec8f170fbcf6c8d355ca4f607beb211e07c0632d03111d4dc4eca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for streamlit-screen-stats 0.0.82

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.82 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page