
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
streamlit-quantity-text-input
Advanced tools
Streamlit input field that uses the pint library for parsing quantities
This Python module gives you a Streamlit text input field (like st.text_input
) for entering and processing concentrations, volumes, amounts ect. in free-text, yet in an input-safe manner.
The quantity_text_input field uses the pint library to parse the user's input as a quantity (volume, speed, concentration etc.).
$ pip install streamlit-quantity-text-input
from streamlit_quantity_text_input import quantity_text_input
vol = quantity_text_input(
"Please input a volume:",
mandatory_dimension="volume",
output_unit="ml",
lower_limit="0 l")
print(f"You input volume is: {vol if vol else 'pending'}")
Check out the accompanying demo.py
for a more detailed example and documentation.
Wanted but not yet planned:
Test cases: Unit tests, perhaps via the doctest module.
Flag: relaxed_time_input
. Implement a flag to allow a much broader range of types of time inputs to be parsed correctly, consistently (e.g. 1h45
, 1hrs3minutes
, 2wks60'45"
etc.). Bonus points for offering a solution that also addresses Danish spellings (perhaps as a pre-parser).
Fool-profing the math parser: The pint library treats scalars and units equally, which can lead to some unexpected parsing when mixing scalars and units (1 m / 2 s
parses into 1*m/2*s
=½ m*s
, not ½ m/s
). Presumably, this can be fixed by tokenizing the input string and 'gluing' scalars and their abutting unit(s) together with parenthesis (((1*m)/(2*s))
). However, writing the tokenizer could be non-trivial.
See LICENSE.txt
New as of April 2024.
FAQs
Streamlit input field that uses the pint library for parsing quantities
We found that streamlit-quantity-text-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.