st.set_page_config语法:
st.set_page_config(page_title=None, page_icon=None, layout=“centered”, initial_sidebar_state=“auto”, menu_items=None)
参数说明:
- page_title (字符 或 None)
页标题,显示在浏览器标签上。如果为None,则缺省为脚本的文件名 (“app.py” 将显示为 “app • Streamlit”).
- page_icon (Anything supported by st.image or str or None)
网页图标. 除st.image (如 URLs 或 numpy数组)支持的类型外, 您可以传入emoji 作为字符串 (“🦈”) 或者 a shortcode ("🦈"). 如果您觉得足够幸运, 试试 “random” 来获取一个随机的emoji! Emoji icons由Twemoji免费提供,从MaxCDN载入。
- layout (“centered” or “wide”)
页面元素布局,缺省为 “centered”; “wide” 将使用整个屏幕.
- initial_sidebar_state (“auto” or “expanded” or “collapsed”)
设置边栏的初始状态. 缺省为 “auto”, 将在移动迟寸的设备上隐藏边栏, 否则显示。 “expanded” 设置为初始显示; “collapsed” 设置为折叠。
- menu_items (dict)
配置页面顶部最右端的菜单。包括:
- “Get help”: str or None The URL this menu item should point to. If None, hides this menu item.
- “Report a Bug”: 字符 or None。 该菜单项指向的URL. 如果为None, 则隐藏该菜单项.
- “About”: str or None A markdown string to show in the About dialog. If None, only shows Streamlit’s default About text.
注意:set_page_config() 在每个APP里智能调用一次,且必须在脚本中的第一行,否则将报错:
StreamlitAPIException: set_page_config() can only be called once per app, and must be called as the first Streamlit command in your script.