streamlit

Форк
0
/
st_expander.py 
69 строк · 2.6 Кб
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
import streamlit as st
16

17
sidebar = st.sidebar.expander("Expand me!")
18
sidebar.write("I am in the sidebar")
19

20
expander = st.expander("Collapse me!", expanded=True)
21
expander.write("I can collapse")
22
expander.slider("I don't get cut off")
23
expander.button("I'm also not cut off (while focused)")
24

25
collapsed = st.expander("_Expand_ **me**!")
26
collapsed.write("I am already collapsed")
27

28
st.expander("Empty expander")
29

30
with st.expander("Expander with number input", expanded=True):
31
    # We deliberately use a list to implement this for the screenshot
32
    st.write("* Example list item")
33
    value = st.number_input("number", value=1.0, key="number")
34

35

36
def update_value():
37
    st.session_state.number = 0
38

39

40
update_button = st.button("Update Num Input", on_click=update_value)
41

42
st.text(st.session_state.number)
43

44
if st.button("Print State Value"):
45
    st.text(st.session_state.number)
46

47
expander_long = st.expander(
48
    "Expand me! "
49
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum arcu nisl, tincidunt id "
50
    "orci id, condimentum cursus nunc. Nullam sed sodales ipsum, vel tincidunt dui. Etiam diam "
51
    "dolor, eleifend sit amet purus id, dictum aliquam quam.",
52
    expanded=True,
53
)
54
expander_long.write(
55
    "I can collapse. "
56
    "Integer et justo orci. In euismod posuere nulla ac maximus. Mauris tristique hendrerit "
57
    "placerat. Integer eu imperdiet ipsum. Praesent maximus pharetra est, ut ultrices ante "
58
    "molestie id. Nulla sollicitudin arcu orci, eget lobortis lacus ultricies eu. Ut suscipit est "
59
    "eget tellus laoreet faucibus. Nullam nec blandit felis. Nulla ullamcorper, justo eget "
60
    "consequat ultricies, nisi dolor lacinia mauris, eu lacinia ante nisi sit amet tortor."
61
)
62

63
collapsed_long = st.expander(
64
    "Expand me! "
65
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum arcu nisl, tincidunt id "
66
    "orci id, condimentum cursus nunc. Nullam sed sodales ipsum, vel tincidunt dui. Etiam diam "
67
    "dolor, eleifend sit amet purus id, dictum aliquam quam."
68
)
69
collapsed_long.write("I am already collapsed")
70

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

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

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

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