st-annotated-text


Namest-annotated-text JSON
Version 4.0.0 PyPI version JSON
download
home_pagehttps://github.com/tvst/st-annotated-text
SummaryA simple component to display annotated text in Streamlit apps.
upload_time2023-04-05 21:11:15
maintainer
docs_urlNone
authorThiago Teixeira
requires_python>=3.5
licenseApache 2
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Annotated Text Component for Streamlit

A simple component to display annotated text in Streamlit apps. For example:

![Example image](https://github.com/tvst/st-annotated-text/raw/master/example.png)


## Installation

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

```bash
pip install streamlit
pip install st-annotated-text
```


## Example

```python
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:

```python
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](https://github.com/tvst/htbuilder) 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.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tvst/st-annotated-text",
    "name": "st-annotated-text",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "",
    "author": "Thiago Teixeira",
    "author_email": "me@thiagot.com",
    "download_url": "https://files.pythonhosted.org/packages/11/aa/2a864928abfdcc1eec13a1c19cb1c1f908936b012fdd276ef55cd1d1e3ea/st-annotated-text-4.0.0.tar.gz",
    "platform": null,
    "description": "# Annotated Text Component for Streamlit\n\nA simple component to display annotated text in Streamlit apps. For example:\n\n![Example image](https://github.com/tvst/st-annotated-text/raw/master/example.png)\n\n\n## Installation\n\nFirst install Streamlit (of course!) then pip-install this library:\n\n```bash\npip install streamlit\npip install st-annotated-text\n```\n\n\n## Example\n\n```python\nimport streamlit as st\nfrom annotated_text import annotated_text\n\nannotated_text(\n    \"This \",\n    (\"is\", \"verb\"),\n    \" some \",\n    (\"annotated\", \"adj\"),\n    (\"text\", \"noun\"),\n    \" for those of \",\n    (\"you\", \"pronoun\"),\n    \" who \",\n    (\"like\", \"verb\"),\n    \" this sort of \",\n    (\"thing\", \"noun\"),\n    \".\"\n)\n```\n\nAnd you can customize colors:\n\n```python\nannotated_text(\n    \"This \",\n    (\"is\", \"verb\", \"#8ef\"),\n    \" some \",\n    (\"annotated\", \"adj\", \"#faa\"),\n    (\"text\", \"noun\", \"#afa\"),\n    \" for those of \",\n    (\"you\", \"pronoun\", \"#fea\"),\n    \" who \",\n    (\"like\", \"verb\", \"#8ef\"),\n    \" this sort of \",\n    (\"thing\", \"noun\", \"#afa\"),\n    \".\"\n)\n```\n\n\n## Parameters\n\nThe `annotated_text()` function accepts any number of the following arguments:\n- strings, to draw the string as-is on the screen.\n- tuples of the form (main_text, annotation_text, background, color) where\n  background and foreground colors are optional and should be an CSS-valid string such as\n  \"#aabbcc\" or \"rgb(10, 20, 30)\"\n- [htbuilder.HtmlElement](https://github.com/tvst/htbuilder) objects in case you want to customize\n  the annotations further. In particular, you can import the `annotation()` function from this\n  module to easily produce annotations whose CSS you can customize via keyword arguments.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2",
    "summary": "A simple component to display annotated text in Streamlit apps.",
    "version": "4.0.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11aa2a864928abfdcc1eec13a1c19cb1c1f908936b012fdd276ef55cd1d1e3ea",
                "md5": "9f3e64e96c5419c1dcd91ebba1f99e86",
                "sha256": "8337fcb3271c7f59a877e0fce5d822613116a4036d06890fc68cf840430b40aa"
            },
            "downloads": -1,
            "filename": "st-annotated-text-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9f3e64e96c5419c1dcd91ebba1f99e86",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 7797,
            "upload_time": "2023-04-05T21:11:15",
            "upload_time_iso_8601": "2023-04-05T21:11:15.203500Z",
            "url": "https://files.pythonhosted.org/packages/11/aa/2a864928abfdcc1eec13a1c19cb1c1f908936b012fdd276ef55cd1d1e3ea/st-annotated-text-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-05 21:11:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "tvst",
    "github_project": "st-annotated-text",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "st-annotated-text"
}
        
Elapsed time: 0.07118s