streamlit

Форк
0
/
st_popover.py 
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

16
import numpy as np
17
import pandas as pd
18

19
import streamlit as st
20

21
# Create random dataframe:
22
np.random.seed(0)
23
df = pd.DataFrame(np.random.randn(50, 5), columns=["a", "b", "c", "d", "e"])
24

25
st.popover("popover 1 (empty)")
26

27
with st.popover("popover 2 (use_container_width)", use_container_width=True):
28
    st.markdown("Hello")
29

30
with st.popover(
31
    "popover 3 (with widgets)",
32
):
33
    st.markdown("Hello World 👋")
34
    text = st.text_input("Text input")
35
    col1, col2, col3 = st.columns(3)
36
    col1.text_input("Column 1")
37
    col2.text_input("Column 2")
38
    col3.text_input("Column 3")
39
    st.selectbox("Selectbox", ["a", "b", "c"])
40

41

42
with st.popover("popover 4 (with dataframe)", help="help text"):
43
    st.markdown("Popover with dataframe")
44
    st.dataframe(df, use_container_width=False)
45
    st.image(np.repeat(0, 100).reshape(10, 10))
46

47
with st.sidebar.popover("popover 5 (in sidebar)"):
48
    st.markdown("Popover in sidebar with dataframe")
49
    st.dataframe(df, use_container_width=True)
50

51
with st.popover("popover 6 (disabled)", disabled=True):
52
    st.markdown("Hello World 👋")
53

54
with st.expander("Output"):
55
    st.markdown(text)
56

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.