GithubHelp home page GithubHelp logo

voltek62 / st-annotated-text Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tvst/st-annotated-text

0.0 1.0 0.0 67 KB

A simple component to display annotated text in Streamlit apps.

License: Apache License 2.0

Python 89.51% Makefile 10.49%

st-annotated-text's Introduction

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(
    "This ",
    ("is", "verb"),
    " some ",
    ("annotated", "adj"),
    ("text", "noun"),
    " for those of ",
    ("you", "pronoun"),
    " who ",
    ("like", "verb"),
    " this sort of ",
    ("thing", "noun"),
    "."
)

And you can customize colors:

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.

st-annotated-text's People

Contributors

tvst avatar mart1nro avatar sai-krishna-msk avatar mataney avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.