| 函数签名[source] | |
|---|---|
st.set_page_config(page_title=None, page_icon=None, layout="centered", initial_sidebar_state="auto", menu_items=None) | |
| 参数 | |
page_title (str or None) | 页面标题,显示在浏览器标签中。如果为None,则默认为脚本的文件名("app.py"将显示为"app • Streamlit")。 |
page_icon (Anything supported by st.image (except list), str, or None) | The page favicon. If page_icon is None (default), the favicon will be a monochrome Streamlit logo. In addition to the types supported by st.image (except list), the following strings are valid:
Note Colors are not supported for Material icons. When you use a Material icon for favicon, it will be black, regardless of browser theme. |
layout ("centered" 或 "wide") | 页面内容应如何布局。默认为 "centered", 将元素限制在一个固定宽度的居中列中; "wide" 使用整个屏幕。 |
initial_sidebar_state ("auto", "expanded", 或 "collapsed") | 侧边栏应如何开始。默认为 "auto", 在小设备上隐藏侧边栏,否则显示。 "expanded" 初始显示侧边栏;"collapsed" 隐藏它。 在大多数情况下,您应该只使用 "auto",否则应用程序在嵌入并在移动设备上查看时会显得不好。 |
menu_items (dict) | 配置出现在此应用程序右上角的菜单。 此字典中的键表示您要配置的菜单项:
URL也可以指向电子邮件地址,例如 mailto:john@example.com。 |
示例
import streamlit as st
st.set_page_config(
page_title="Ex-stream-ly Cool App",
page_icon="🧊",
layout="wide",
initial_sidebar_state="expanded",
menu_items={
'Get Help': 'https://www.extremelycoolapp.com/help',
'Report a bug': "https://www.extremelycoolapp.com/bug",
'About': "# This is a header. This is an *extremely* cool app!"
}
)
还有问题吗?
我们的 论坛 充满了有用的信息和Streamlit专家。