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. For example:

Example image

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 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 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.

To-do

Just one to-do:

  • Write tests! Contributions accepted :wink:

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-3.0.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: st-annotated-text-3.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for st-annotated-text-3.0.0.tar.gz
Algorithm Hash digest
SHA256 b63a55ef03411ce4e37bf9269a32e6ee4b344a658552e3fb0b4924bca0c5dc40
MD5 ffff296ccc4b2e1a9f69ed4bc6200cf1
BLAKE2b-256 2227c7d2662773cf2c08321cbe539abe35a048f9ece32ecfdee5560e987f76d9

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