Qui*_*ten 2 python button hyperlink streamlit
我想创建一个带有超链接的按钮Streamlit。我想也许可以使用st.button这种语法:[Click Here](https://stackoverflow.com)。但不幸的是这没有成功,它只显示文本,并没有将其作为超链接。我找到了这个解决方法,但这不再有效。我不想使用st.markdown超链接,因为这不会创建按钮。这是一个可重现的示例:
"""
# Streamlit app
"""
import streamlit as st
import pandas as pd
# Button with hyperlink
st.button('[Click Here](https://stackoverflow.com)')
Run Code Online (Sandbox Code Playgroud)
输出:
如您所见,它不会创建超链接。所以我想知道是否有人知道如何在 Streamlit 中创建带有超链接的按钮?
您可以使用 Markdowna和button标签。
import streamlit as st
url = 'https://stackoverflow.com'
st.markdown(f'''
<a href={url}><button style="background-color:GreenYellow;">Stackoverflow</button></a>
''',
unsafe_allow_html=True)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5223 次 |
| 最近记录: |