前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Streamlit 自定义跑马灯组件

Streamlit 自定义跑马灯组件

原创
作者头像
月小水长
发布2023-11-17 09:43:59
2310
发布2023-11-17 09:43:59
举报
文章被收录于专栏:月小水长月小水长

近来需要在 streamlit 项目实现跑马灯效果,但是没有现成组件。于是自定义实现了这个组件,并且发布到了 pypi 。

pypi 地址:https://pypi.org/project/streamlit-marquee/

github 源码地址:https://github.com/inspurer/streamlit-marquee

效果如下:

streamlit-marqueen
streamlit-marqueen

使用说明书和简单原理说明本来我是用英文写的,懒得翻译,大家将就下看下。

what is it

a marquee component for streamlit

how to use

first, install via pip online

代码语言:txt
复制
pip install streamlit-marquee

or download the wheel file and install offline

pip install {{the downloaded wheel file path in your pc}}

or just download the source-code.

then, there are two demos below.

demo 1 (recommend)
代码语言:python
代码运行次数:0
复制
from streamlit\_marquee import streamlit\_marquee



streamlit\_marquee(\*\*{

    # the marquee container background color

    'background': "#ff0000",

    # the marquee text size

    'fontSize': '12px',

    # the marquee text color

    "color": "#ffffff",

    # the marquee text content

    'content': 'here is custom marquee component~',

    # the marquee container width

    'width': '600px',

    # the marquee container line height

    'lineHeight': "35px",

    # the marquee duration

    'animationDuration': '5s',

})
demo 2
代码语言:python
代码运行次数:0
复制
from streamlit\_marquee import streamlit\_marquee



streamlit\_marquee(content='here is custom marquee component~')

how it realizes

since the html tag <marquee> has been declared as deprecated.

as an alternative, use css animation to realize.

supported attributes

* background

* fontSize

* color

* content

* width

* lineHeight

* animationDuration

you can also download the source code and change to support more attributes such as transition-timing-function.

any question, please open issues.

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • what is it
  • how to use
  • how it realizes
  • supported attributes
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档