Skip to main content

Component to display avatar icon in Streamlit

Project description

streamlit-avatar

Component to display avatar icon in Streamlit

alt text

Installation instructions

pip install streamlit-avatar

Usage instructions

Simple Usage

import streamlit as st
from streamlit_avatar import avatar

result = avatar(
    [
        {
            "url": "https://picsum.photos/id/237/300/300",
            "size": 40,
            "title": "Sam",
            "caption": "hello",
            "key": "avatar1",
        },
        {
            "url": "https://picsum.photos/id/238/300/300",
            "size": 40,
            "title": "Bob",
            "caption": "happy",
            "key": "avatar2",
        },
        {
            "url": "https://picsum.photos/id/23/300/300",
            "size": 40,
            "title": "Rick",
            "caption": "Bye",
            "key": "avatar3",
        },
    ]
)
st.write(result)

""" Return
{
"title":"Sam"
"cption":"hello"
"key":"avatar1"
}
"""

Using Base64

import streamlit as st
from streamlit_avatar import avatar
import base64

def get_image_base64(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

image_path = "assets/image.png"
image_base64 = get_image_base64(image_path)
image_url = f"data:image/png;base64,{image_base64}"

result = avatar(
    [
        {
            "url": image_url,
            "size": 40,
            "title": "Sam",
            "caption": "hello",
            "key": "avatar1",
        }
    ]
)
st.write(result)

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

streamlit_avatar-0.1.3.tar.gz (402.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_avatar-0.1.3-py3-none-any.whl (779.6 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_avatar-0.1.3.tar.gz.

File metadata

  • Download URL: streamlit_avatar-0.1.3.tar.gz
  • Upload date:
  • Size: 402.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for streamlit_avatar-0.1.3.tar.gz
Algorithm Hash digest
SHA256 023893bd80db5a923d397fc64d27c7a972107da4f0bea0feb99a32f9363f2691
MD5 6fc211d1479ed4747243762328c04ba1
BLAKE2b-256 b7a209c6046b1934f79ce2c6d767f3c7760ce632685498e67af455a2ae962d4a

See more details on using hashes here.

File details

Details for the file streamlit_avatar-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_avatar-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 873e6f0022635eda29d6b76e570adcbc095d8e6d23f18dd1e288720b4736364d
MD5 559ef3fe18d9ace84e252aedcf0219e9
BLAKE2b-256 cf774b82378aa4caf7ef7701841b25a5406b3a3bb6171c8b9eee540553843b7f

See more details on using hashes here.

Supported by

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