配置页面的默认设置。
注意
这必须是您的应用程序中使用的第一个 Streamlit 命令,并且只能设置一次。
函数签名
st.set_page_config(page_title=None, page_icon=None, layout="centered", initial_sidebar_state="auto", menu_items=None)
参数 | 说明 |
---|---|
page_title (str or None) | 页面标题,显示在浏览器选项卡中。如果没有,默认为脚本的文件名("app.py" 将显示“app • Streamlit”)。 |
page_icon (Anything supported by st.image or str or None) | 页面图标。除了 |
layout ("centered" or "wide") | 页面内容应该如何布局。默认为"centered",它将元素限制在一个固定宽度的居中列中; "wide" 使用整个屏幕。 |
initial_sidebar_state ("auto" or "expanded" or "collapsed") | 侧边栏应该如何开始。默认为"auto",在移动设备上隐藏侧边栏,否则显示。 "expanded" 最初显示侧边栏; "collapsed" 隐藏它。 |
menu_items (dict) | 配置显示在此应用右上角的菜单。此 dict 中的键表示您要配置的菜单项:
|
示例
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!"
}
)
相关用法
- Python Streamlit st.selectbox用法及代码示例
- Python Streamlit st.select_slider用法及代码示例
- Python Streamlit st.slider用法及代码示例
- Python Streamlit st.spinner用法及代码示例
- Python Streamlit st.subheader用法及代码示例
- Python Streamlit st.success用法及代码示例
- Python Streamlit st.snow用法及代码示例
- Python Streamlit st.stop用法及代码示例
- Python Streamlit st.experimental_singleton.clear用法及代码示例
- Python Streamlit st.bokeh_chart用法及代码示例
- Python Streamlit st.caption用法及代码示例
- Python Streamlit st.text_input用法及代码示例
- Python Streamlit st.area_chart用法及代码示例
- Python Streamlit st.title用法及代码示例
- Python Streamlit st.cache用法及代码示例
- Python Streamlit st.experimental_singleton用法及代码示例
- Python Streamlit st.empty用法及代码示例
- Python Streamlit st.error用法及代码示例
- Python Streamlit st.video用法及代码示例
- Python Streamlit st.vega_lite_chart用法及代码示例
- Python Streamlit st.header用法及代码示例
- Python Streamlit st.container用法及代码示例
- Python Streamlit st.form_submit_button用法及代码示例
- Python Streamlit st.form用法及代码示例
- Python Streamlit st.plotly_chart用法及代码示例
注:本文由纯净天空筛选整理自streamlit.io大神的英文原创作品 st.set_page_config。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。