-
Notifications
You must be signed in to change notification settings - Fork 108
/
cheat sheet.py
49 lines (40 loc) · 1.54 KB
/
cheat sheet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# StreamlitApp
import streamlit as st
def main():
st.title("Streamlit Cheat Sheet")
# Section: Text and Titles
st.header("Text and Titles")
st.write("Streamlit provides various commands for displaying text and titles:")
st.code("st.title('Title')")
st.code("st.header('Header')")
st.code("st.subheader('Subheader')")
st.code("st.write('Text')")
# Section: Markdown
st.header("Markdown")
st.write("You can use Markdown for rich text formatting:")
st.code("st.markdown('**Bold** *Italic* [Link](https://www.example.com)')")
# Section: Data Display
st.header("Data Display")
st.write("Commands for displaying data:")
st.code("st.dataframe(data)")
st.code("st.table(data)")
st.code("st.json(data)")
# Section: Interactive Widgets
st.header("Interactive Widgets")
st.write("Streamlit allows you to create interactive widgets:")
st.code("st.text_input('Enter text:', 'Default Value')")
st.code("st.selectbox('Select option:', ['Option 1', 'Option 2', 'Option 3'])")
st.code("st.slider('Select a value:', 0, 100, 50)")
# Section: Buttons
st.header("Buttons")
st.write("Create buttons with st.button:")
st.code("if st.button('Click me'):")
st.code(" st.write('Button clicked!')")
# Section: Progress Bar
st.header("Progress Bar")
st.write("Display a progress bar:")
st.code("progress_bar = st.progress(0)")
st.code("for i in range(100):")
st.code(" progress_bar.progress(i + 1)")
if __name__ == "__main__":
main()