-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
139 lines (91 loc) · 2.83 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
"""
Streamlit Cheat Sheet
App to summarise streamlit docs v1.25.0
There is also an accompanying png and pdf version
https://github.com/daniellewisDL/streamlit-cheat-sheet
v1.25.0
03 June 2024
"""
import streamlit as st
from pathlib import Path
import base64
# Initial page config
st.set_page_config(
page_title='My own cheat sheet',
layout="wide",
initial_sidebar_state="expanded",
)
def main():
cs_sidebar()
cs_body()
return None
# Thanks to streamlitopedia for the following code snippet
def img_to_bytes(img_path):
img_bytes = Path(img_path).read_bytes()
encoded = base64.b64encode(img_bytes).decode()
return encoded
# sidebar
def cs_sidebar():
st.sidebar.markdown(
'''[<img src='data:image/png;base64,{}' class='img-fluid' width=32 height=32>](https://streamlit.io/)'''.format(
img_to_bytes("logomark_website.png")), unsafe_allow_html=True)
st.sidebar.header('Streamlit cheat sheet')
st.sidebar.markdown('''
<small>Das ist mein Cheatsheet</small>
''', unsafe_allow_html=True)
st.sidebar.markdown('__Install and import__')
st.sidebar.code('$ pip install streamlit')
st.sidebar.markdown('__Command line__')
st.sidebar.code('''
$ streamlit --help
$ streamlit run your_script.py
$ streamlit docs
$ streamlit --version
''')
st.sidebar.markdown(
'<small>Learn more about [streamlit experimental features](https://docs.streamlit.io/library/advanced-features/prerelease#beta-and-experimental-features)</small>',
unsafe_allow_html=True)
st.sidebar.markdown('''<hr>''', unsafe_allow_html=True)
st.sidebar.markdown(
'''<small>[Cheat sheet v1.25.0](https://github.com/daniellewisDL/streamlit-cheat-sheet) | Juni 2024 | [Mai](https://github.com/phuong-mai-mai)</small>''',
unsafe_allow_html=True)
return None
##########################
# Main body of cheat sheet
##########################
def cs_body():
col1, col2 = st.columns(2)
#######################################
# COLUMN 1
#######################################
# Display text
col1.subheader('Git commands')
col1.code('''
your commands
''')
# Display data
col1.subheader('Other code')
col1.code('''
''')
#######################################
# COLUMN 2
#######################################
# Display interactive widgets
col2.subheader('Other code')
col2.code('''
''')
col2.code('''
''')
col2.code('''
''')
# Build chat-based apps
col2.subheader('More Code')
col2.code('''
''')
col2.markdown(
'<small>Learn how to [build chat-based apps](https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps)</small>',
unsafe_allow_html=True)
return None
# Run main()
if __name__ == '__main__':
main()