可以互相切换的streamlit的uploader方案

/*思路定义def函数*/

def generate_css(language):

    if language == 'en':

        before_content = "Drag files here"

        after_content = "The maximum limit for each file is 200MB."

        button_content = "Browse file"

    else:

        before_content = "将文件拖放到此处"

        after_content = "每个文件最大限制200MB"

        button_content = "浏览文件"



    css = f'''

<style>

    [data-testid="stFileUploaderDropzone"] div div::before {{

        content: "{before_content}";

    }}

    [data-testid="stFileUploaderDropzone"] div div span {{

        display: none;

    }}

    [data-testid="stFileUploaderDropzone"] div div::after {{

        color: rgba(49, 51, 63, 0.6);

        font-size: .8em;

        content: "{after_content}";

    }}

    [data-testid="stFileUploaderDropzone"] div div small {{

        display: none;

    }}

    [data-testid="stFileUploaderDropzone"] [data-testid="stBaseButton-secondary"] {{

        font-size: 0px;

    }}

    [data-testid="stFileUploaderDropzone"] [data-testid="stBaseButton-secondary"]::after {{

        content: "{button_content}";

        font-size: 17px !important;

    }}

</style>

'''

    return css





的最后需要设置st.markdown(css, unsafe_allow_html=True),这样就可以在中英文页面显示不同的,然后需要根据页面不同设置 css = generate_css('en')或者 css = generate_css('cn'),需注意若不能正常显示需要修改data-testid,在浏览器进入f12查看id后修改

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值