Extra-Streamlit-Components 使用教程

Extra-Streamlit-Components 使用教程

Extra-Streamlit-ComponentsAn all in one place, to find complex or just not available components by default on streamlit.项目地址:https://gitcode.com/gh_mirrors/ex/Extra-Streamlit-Components

1、项目介绍

Extra-Streamlit-Components 是一个开源项目,旨在为 Streamlit 提供额外的复杂或默认不可用的组件。该项目由 Mohamed Abdou 开发,支持 Python 3.6 及以上版本,并采用 MIT 许可证。通过这个项目,开发者可以轻松地扩展 Streamlit 的功能,添加自定义组件,如标签栏、动态图像等。

2、项目快速启动

安装

首先,通过 pip 安装 extra-streamlit-components

pip install extra-streamlit-components

示例代码

以下是一个简单的示例,展示如何在 Streamlit 应用中使用 extra-streamlit-components

import streamlit as st
import extra_streamlit_components as stx

# 创建标签栏
chosen_id = stx.tab_bar(data=[
    stx.TabBarItemData(id=1, title="ToDo", description="Tasks to take care of"),
    stx.TabBarItemData(id=2, title="Done", description="Tasks taken care of"),
    stx.TabBarItemData(id=3, title="Overdue", description="Tasks missed out")
], default=1)

# 显示选中的标签
st.info(f"Chosen ID: {chosen_id}")

# 显示动态图像
image_urls = [
    "https://streamlit.io/images/brand/streamlit-logo-secondary-colormark-darktext.svg",
    "https://streamlit.io/images/brand/streamlit-logo-secondary-lightmark-lighttext.png",
    "https://ruslanmv.com/assets/images/posts/2020-10-17-Web-Application-Classification/streamlit_logo.png"
]
stx.bouncing_image(image_source=image_urls[int(chosen_id) - 1], animate=True, animation_time=1500, height=200, width=600)

3、应用案例和最佳实践

应用案例

  • 任务管理应用:使用标签栏组件来管理不同状态的任务(如待办、已完成、逾期)。
  • 动态图像展示:利用动态图像组件展示不同状态下的图像,增强用户交互体验。

最佳实践

  • 模块化设计:将自定义组件封装成独立的模块,便于管理和复用。
  • 缓存优化:使用 st.cache_resource 装饰器缓存资源,提高应用性能。

4、典型生态项目

  • Streamlit-Authenticator:一个用于 Streamlit 应用的身份验证组件,增强应用的安全性。
  • Streamlit-Aggrid:提供在 Streamlit 中使用 Ag-Grid 的功能,增强数据表格的交互性。

通过这些生态项目,可以进一步扩展 Streamlit 的功能,构建更强大和丰富的应用。

Extra-Streamlit-ComponentsAn all in one place, to find complex or just not available components by default on streamlit.项目地址:https://gitcode.com/gh_mirrors/ex/Extra-Streamlit-Components

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

董向越

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值