A simple component to display annotated text in Streamlit apps.
Project description
Annotated Text Component for Streamlit
A simple component to display annotated text in Streamlit apps. For example:
Or, even better, check out our demo app here:
Installation
First install Streamlit (of course!) then pip-install this library:
pip install streamlit
pip install st-annotated-text
Example
import streamlit as st
from annotated_text import annotated_text
annotated_text(
"This ",
("is", "verb"),
" some ",
("annotated", "adj"),
("text", "noun"),
" for those of ",
("you", "pronoun"),
" who ",
("like", "verb"),
" this sort of ",
("thing", "noun"),
"."
)
For more examples, including :sparkles:customization options:sparkles:, see the demo app.
Parameters
The annotated_text()
function accepts any number of the following arguments:
- strings, to draw the string as-is on the screen.
- tuples of the form (main_text, annotation_text, background, color) where background and foreground colors are optional and should be an CSS-valid string such as "#aabbcc" or "rgb(10, 20, 30)"
- htbuilder.HtmlElement objects in case you want to customize
the annotations further. In particular, you can import the
annotation()
function from this module to easily produce annotations whose CSS you can customize via keyword arguments. - lists of any of the above -- or of lists!
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 st-annotated-text-4.0.1.tar.gz
.
File metadata
- Download URL: st-annotated-text-4.0.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ccb9a35c078ef22c6ebb244a9a0605ce27f1fd699f55939497669081b79630 |
|
MD5 | 503fc3bdd2b63fdd05cffb046445903a |
|
BLAKE2b-256 | eed550a8d4781079e6f637f921468d93b344f37fffa2845324ded891f2b1a52a |
File details
Details for the file st_annotated_text-4.0.1-py3-none-any.whl
.
File metadata
- Download URL: st_annotated_text-4.0.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a2a72903a5752a55c0acef71bdf92cd225a23a8ae4135cfc213c4538bed432f |
|
MD5 | 52089bec6964abd9f912d7ee48d7b5be |
|
BLAKE2b-256 | 58a83ea10541bd8946e2a4b47b702a82ad4dc06ca30670952bf3e21609f26e4a |