首页后端开发PythonStreamlit 自定义跑马灯组件

Streamlit 自定义跑马灯组件

时间2023-12-08 15:39:03发布访客分类Python浏览1533
导读:近来需要在 streamlit 项目实现跑马灯效果,但是没有现成组件。于是自定义实现了这个组件,并且发布到了 pypi 。pypi 地址:https://pypi.org/project/streamlit-marquee/github 源...

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

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

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

效果如下:

streamlit-marqueenstreamlit-marqueen

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

what is it

a marquee component for streamlit

how to use

first, install via pip online

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)
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
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.

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: Streamlit 自定义跑马灯组件
本文地址: https://pptw.com/jishu/573444.html
Python如何使用Pyecharts+TextRank生成词云图? 解决Requests中使用httpbin服务器问题:自定义URL的实现与验证

游客 回复需填写必要信息