python︱写markdown一样写网页,代码快速生成web工具:streamlit lay-out布局(四)
2023-04-18 14:06:40 时间
文章目录
系列参考:
python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重要组件介绍(二) python︱写markdown一样写网页,代码快速生成web工具:streamlit 展示组件(三) python︱写markdown一样写网页,代码快速生成web工具:streamlit lay-out布局(四) python︱写markdown一样写网页,代码快速生成web工具:streamlit 缓存(五) python︱写markdown一样写网页,代码快速生成web工具:streamlit 数据探索案例(六) streamlit + opencv/YOLOv3 快速构建自己的图像目标检测demo网页(七)
github代码链接:mattzheng/streamlit_demo
1 streamlit.beta_container()
通过with st.beta_container():
,可以Book一个组件模块
将一个不可见的容器插入到你的应用程序中,可以用来保存多个元素。
# with写法
with st.beta_container():
st.write("This is inside the container")
# You can call any Streamlit command, including custom components:
st.bar_chart(np.random.randn(50, 3))
st.write("This is outside the container")
# 常规写法
container = st.beta_container()
container.write("This is inside the container")
st.write("This is outside the container")
# Now insert some more in the container
container.write("This is inside too")
2 分列展示
streamlit.beta_columns(spec)
以并排列的形式插入容器。插入多个并排放置的多元素容器,并返回容器对象列表。
要向返回的容器添加元素,可以使用“with”表示法(首选),或者直接调用返回对象的方法。
请参见下面的例子。
col1, col2, col3 = st.beta_columns(3)
with col1:
st.header("A cat")
st.image("https://static.streamlit.io/examples/cat.jpg", use_column_width=True)
with col2:
st.header("A dog")
st.image("https://static.streamlit.io/examples/dog.jpg", use_column_width=True)
with col3:
st.header("An owl")
st.image("https://static.streamlit.io/examples/owl.jpg", use_column_width=True)
3 按照比例分列展示
col1, col2 = st.beta_columns([3, 1])
data = np.random.randn(10, 1)
col1.subheader("A wide column with a chart")
col1.line_chart(data)
col2.subheader("A narrow column with the data")
col2.write(data)
4 折叠/展开
streamlit.beta_expander(label=None, expanded=False)
st.line_chart({"data": [1, 5, 2, 6, 2, 1]})
with st.beta_expander("See explanation"):
st.write("""
The chart above shows some numbers I picked for you.
I rolled actual dice for these, so they're *guaranteed* to
be random.
""")
st.image("https://static.streamlit.io/examples/dice.jpg")
相关文章
- Python使用tkinter组件Label显示简单数学公式
- 内网渗透之DCOM横向移动
- 以目标为导向的语义交流的共同语言——一个课程学习框架
- python爬虫前奏【成信笔记】
- HTML 5 File API:文件拖放上传功能
- 教你快速创建 Python 虚拟环境
- pyenv 实现Python多版本自由切换
- 用 Python 对 Excel文件进行批量操作
- Python - 接入钉钉机器人
- Python - 抓取 iphone13 pro 线下店供货信息并发送到钉钉机器人,最后设置为定时任务
- crontab - 解决 mac 下通过 crontab 设置了 Python 脚本的定时任务却无法运行
- [源码解析] PyTorch分布式(5) ------ DistributedDataParallel 总述&如何使用
- Python科普系列——类与方法(上篇)
- SAP对STO的交货单执行PGI,报错 -Fld selectn for mvmt type 643 acct 400020 differs
- Spring Boot 实现通用 Auth 认证的 4 种方式
- 盘点4种使用Python批量合并同一文件夹内所有子文件夹下的Excel文件内所有Sheet数据
- OushuDB 学习经验分享(三):技术特点
- Java和Python思维方式的不同之处
- Python中日志记录新技能
- 奥比中光Gemini OpenCV—Python使用