streamlit
55 строк · 1.7 Кб
1# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16import numpy as np17import pandas as pd18
19import streamlit as st20
21# Create random dataframe:
22np.random.seed(0)23df = pd.DataFrame(np.random.randn(50, 5), columns=["a", "b", "c", "d", "e"])24
25st.popover("popover 1 (empty)")26
27with st.popover("popover 2 (use_container_width)", use_container_width=True):28st.markdown("Hello")29
30with st.popover(31"popover 3 (with widgets)",32):33st.markdown("Hello World 👋")34text = st.text_input("Text input")35col1, col2, col3 = st.columns(3)36col1.text_input("Column 1")37col2.text_input("Column 2")38col3.text_input("Column 3")39st.selectbox("Selectbox", ["a", "b", "c"])40
41
42with st.popover("popover 4 (with dataframe)", help="help text"):43st.markdown("Popover with dataframe")44st.dataframe(df, use_container_width=False)45st.image(np.repeat(0, 100).reshape(10, 10))46
47with st.sidebar.popover("popover 5 (in sidebar)"):48st.markdown("Popover in sidebar with dataframe")49st.dataframe(df, use_container_width=True)50
51with st.popover("popover 6 (disabled)", disabled=True):52st.markdown("Hello World 👋")53
54with st.expander("Output"):55st.markdown(text)56