forked from samdobson/streamlit-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
111 lines (98 loc) · 2.46 KB
/
app.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
import streamlit as st
from streamlit_metrics import metric, metric_row
from streamlit_ace import st_ace
import pandas as pd
import numpy as np
import altair as alt
import cufflinks as cf
st.set_page_config(
page_title="Streamlit Sandbox",
page_icon=":memo:",
layout="wide",
initial_sidebar_state="collapsed",
)
st.sidebar.title(":memo: Editor settings")
st.title("Streamlit sandbox")
st.write("Play with Streamlit live in the browser!")
THEMES = [
"ambiance",
"chaos",
"chrome",
"clouds",
"clouds_midnight",
"cobalt",
"crimson_editor",
"dawn",
"dracula",
"dreamweaver",
"eclipse",
"github",
"gob",
"gruvbox",
"idle_fingers",
"iplastic",
"katzenmilch",
"kr_theme",
"kuroir",
"merbivore",
"merbivore_soft",
"mono_industrial",
"monokai",
"nord_dark",
"pastel_on_dark",
"solarized_dark",
"solarized_light",
"sqlserver",
"terminal",
"textmate",
"tomorrow",
"tomorrow_night",
"tomorrow_night_blue",
"tomorrow_night_bright",
"tomorrow_night_eighties",
"twilight",
"vibrant_ink",
"xcode",
]
KEYBINDINGS = ["emacs", "sublime", "vim", "vscode"]
editor, app = st.tabs(["Editor", "App"])
INITIAL_CODE = """
table_data = {'Column 1': [1, 2], 'Column 2': [3, 4]}
st.write(pd.DataFrame(data=table_data))
"""
with editor:
code = st_ace(
value=INITIAL_CODE,
language="python",
placeholder="st.header('Hello world!')",
theme=st.sidebar.selectbox("Theme", options=THEMES, index=26),
keybinding=st.sidebar.selectbox(
"Keybinding mode", options=KEYBINDINGS, index=3
),
font_size=st.sidebar.slider("Font size", 5, 24, 14),
tab_size=st.sidebar.slider("Tab size", 1, 8, 4),
wrap=st.sidebar.checkbox("Wrap lines", value=False),
show_gutter=True,
show_print_margin=True,
auto_update=False,
readonly=False,
key="ace-editor",
)
st.write("Hit `CTRL+ENTER` to refresh")
st.write("*Remember to save your code separately!*")
with app:
exec(code)
with st.sidebar:
libraries_available = st.expander("Available Libraries")
with libraries_available:
st.write(
"""
* Pandas (pd)
* Numpy (np)
* Altair (alt)
* Bokeh
* Plotly
* Cufflinks (cf)
[Need something else?](https://github.com/samdobson/streamlit-sandbox/issues/new)
"""
)