streamlit
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
15import streamlit as st
16
17st.error("This is an error")
18st.warning("This is a warning")
19st.info("This is an info message")
20st.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.
24st.write("Some non-alert text!")
25
26st.error("This is an error", icon="🚨")
27st.warning("This is a warning", icon="⚠️")
28st.info("This is an info message", icon="👉🏻")
29st.success("This is a success message", icon="✅")
30
31# Verify that line-wrapping works as expected both with and without break words.
32st.error("A" + 100 * "H")
33st.error("If I repeat myself enough the line should " + 20 * "wrap ")
34
35text = """
36This is an example error from caching.py
37
38This error can occur when your virtual environment lives in the same
39folder as your project, since that makes it hard for Streamlit to
40understand which files it should check. If you think that's what caused
41this, please add the following to `~/.streamlit/config.toml`:
42
43```toml
44[server]
45folderWatchBlacklist = ['foldername']
46```
47
48...where `foldername` is the relative or absolute path to the folder
49where you put your virtual environment.
50
51Otherwise, please [file a bug
52here](https://github.com/streamlit/streamlit/issues/new/choose).
53
54To stop this warning from showing in the meantime, try one of the
55following:
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
61st.error(text)
62st.warning(text)
63st.info(text)
64st.success(text)
65
66# Check resolution of issue #6394
67text = """
68Here is some code:
69
70```
71import streamlit as st
72st.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
77st.error(text, icon="🚨")
78st.success(text)
79