Skip to main content

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.

Installation

First install Streamlit (of course!) then pip-install this library:

pip install streamlit
pip install st-annotated-text

Examples

import streamlit as st
from st_annotated_text import annotated_text

"""
# Annotated text example

Below is an example of how to use the annotated_text function:
"""

annotated_text(
    "This ",
    ("is", "verb", "#8ef"),
    " some ",
    ("annotated", "adj", "#faa"),
    ("text", "noun", "#afa"),
    " for those of ",
    ("you", "pronoun", "#fea"),
    " who ",
    ("like", "verb", "#8ef"),
    " this sort of ",
    ("thing", "noun", "#afa"),
)

Parameters

The annotated_text() function accepts any 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.

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

st-annotated-text-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file st-annotated-text-1.0.1.tar.gz.

File metadata

  • Download URL: st-annotated-text-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for st-annotated-text-1.0.1.tar.gz
Algorithm Hash digest
SHA256 da31f554b67cf69d4d68a9079d2c0efe39eb7251405c0bfd8f9aaa28b84828fe
MD5 8c2dfa06d94ff51239addb202c4ae6fa
BLAKE2b-256 df9946a1c7135cdc9ed6b3c8a34f2d5fe176960798e51e926caf77352a467c8f

See more details on using hashes here.

Provenance

Supported by

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