配置頁麵的默認設置。
注意
這必須是您的應用程序中使用的第一個 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。