streamlit

Форк
0
78 строк · 2.5 Кб
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
st.error("This is an error")
18
st.warning("This is a warning")
19
st.info("This is an info message")
20
st.success("This is a success message")
21

22
# This is here so we can test the distance between alert messages and
23
# elements above/below them.
24
st.write("Some non-alert text!")
25

26
st.error("This is an error", icon="🚨")
27
st.warning("This is a warning", icon="⚠️")
28
st.info("This is an info message", icon="👉🏻")
29
st.success("This is a success message", icon="✅")
30

31
# Verify that line-wrapping works as expected both with and without break words.
32
st.error("A" + 100 * "H")
33
st.error("If I repeat myself enough the line should " + 20 * "wrap ")
34

35
text = """
36
    This is an example error from caching.py
37

38
    This error can occur when your virtual environment lives in the same
39
    folder as your project, since that makes it hard for Streamlit to
40
    understand which files it should check. If you think that's what caused
41
    this, please add the following to `~/.streamlit/config.toml`:
42

43
    ```toml
44
    [server]
45
    folderWatchBlacklist = ['foldername']
46
    ```
47

48
    ...where `foldername` is the relative or absolute path to the folder
49
    where you put your virtual environment.
50

51
    Otherwise, please [file a bug
52
    here](https://github.com/streamlit/streamlit/issues/new/choose).
53

54
    To stop this warning from showing in the meantime, try one of the
55
    following:
56

57
    * **Preferred:** modify your code to avoid using this type of object.
58
    * Or add the argument `allow_output_mutation=True` to the `st.cache` decorator.
59
    """
60

61
st.error(text)
62
st.warning(text)
63
st.info(text)
64
st.success(text)
65

66
# Check resolution of issue #6394
67
text = """
68
Here is some code:
69

70
```
71
import streamlit as st
72
st.write("Hello world!")
73
# this is a very long comment just to demonstrate the overflowing behavior it goes on and on and on
74
```
75
"""
76

77
st.error(text, icon="🚨")
78
st.success(text)
79

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

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

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

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