whitphx HF Staff commited on
Commit
a7916dc
·
1 Parent(s): f1c1569

Add custom component samples

Browse files
app.py ADDED
File without changes
auth_config.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ credentials:
2
+ usernames:
3
+ jsmith:
4
+ email: jsmith@gmail.com
5
+ name: John Smith
6
+ password: $2b$12$JfcV2rgAU4dfNr.jfYz0LeV8Ycu7RbJuT5jkXdmCu66PR8AvmZ0/S
7
+ rbriggs:
8
+ email: rbriggs@gmail.com
9
+ name: Rebecca Briggs
10
+ password: $2b$12$LaJARFLX/Or.6VqylLF4Kusz6UfRO1jUtL.OCwFROS1a4PmfB.Gky
11
+ cookie:
12
+ expiry_days: 30
13
+ key: Gaithimio9iy8opheephei0peix9ceefiahaekoh3liqu1ongoophiephath0vee
14
+ name: hf-spaces-streamlit-gallery
15
+ preauthorized:
16
+ emails:
17
+ - melsby@gmail.com
pages/3dmol.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from stmol import *
2
+ showmol(render_pdb(id = '1A2C'))
pages/Ace.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from streamlit_ace import st_ace
4
+
5
+ # Spawn a new Ace editor
6
+ content = st_ace()
7
+
8
+ # Display editor's content as you type
9
+ content
pages/AgGrid.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from st_aggrid import AgGrid
2
+ import pandas as pd
3
+
4
+ df = pd.read_csv('https://raw.githubusercontent.com/fivethirtyeight/data/master/airline-safety/airline-safety.csv')
5
+ AgGrid(df)
pages/Agraph.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit
2
+ from streamlit_agraph import agraph, Node, Edge, Config
3
+
4
+ nodes = []
5
+ edges = []
6
+ nodes.append( Node(id="Spiderman",
7
+ label="Peter Parker",
8
+ size=25,
9
+ shape="circularImage",
10
+ image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_spiderman.png")
11
+ ) # includes **kwargs
12
+ nodes.append( Node(id="Captain_Marvel",
13
+ size=25,
14
+ shape="circularImage",
15
+ image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_captainmarvel.png")
16
+ )
17
+ edges.append( Edge(source="Captain_Marvel",
18
+ label="friend_of",
19
+ target="Spiderman",
20
+ # **kwargs
21
+ )
22
+ )
23
+
24
+ config = Config(width=750,
25
+ height=950,
26
+ directed=True,
27
+ physics=True,
28
+ hierarchical=False,
29
+ # **kwargs
30
+ )
31
+
32
+ return_value = agraph(nodes=nodes,
33
+ edges=edges,
34
+ config=config)
pages/Analytics.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import streamlit_analytics
3
+
4
+ with streamlit_analytics.track():
5
+ st.text_input("Write something")
6
+ st.button("Click me")
pages/Annotated_Text.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from annotated_text import annotated_text
3
+
4
+ annotated_text(
5
+ "This ",
6
+ ("is", "verb"),
7
+ " some ",
8
+ ("annotated", "adj"),
9
+ ("text", "noun"),
10
+ " for those of ",
11
+ ("you", "pronoun"),
12
+ " who ",
13
+ ("like", "verb"),
14
+ " this sort of ",
15
+ ("thing", "noun"),
16
+ "."
17
+ )
pages/Authenticator.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ import streamlit as st
4
+ import streamlit_authenticator as stauth
5
+
6
+ with open('./auth_config.yaml') as file:
7
+ config = yaml.load(file, Loader=yaml.SafeLoader)
8
+
9
+ authenticator = stauth.Authenticate(
10
+ config['credentials'],
11
+ config['cookie']['name'],
12
+ config['cookie']['key'],
13
+ config['cookie']['expiry_days'],
14
+ config['preauthorized']
15
+ )
16
+
17
+ name, authentication_status, username = authenticator.login('Login', 'main')
18
+
19
+ if authentication_status:
20
+ authenticator.logout('Logout', 'main')
21
+ st.write(f'Welcome *{name}*')
22
+ st.title('Some content')
23
+ elif authentication_status is False:
24
+ st.error('Username/password is incorrect')
25
+ elif authentication_status is None:
26
+ st.warning('Please enter your username and password')
pages/Bokeh_Events.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from bokeh.plotting import figure
3
+ from bokeh.models import ColumnDataSource, CustomJS
4
+
5
+ # import function
6
+ from streamlit_bokeh_events import streamlit_bokeh_events
7
+
8
+ # create plot
9
+ p = figure(tools="lasso_select")
10
+ cds = ColumnDataSource(
11
+ data={
12
+ "x": [1, 2, 3, 4],
13
+ "y": [4, 5, 6, 7],
14
+ }
15
+ )
16
+ p.circle("x", "y", source=cds)
17
+
18
+ # define events
19
+ cds.selected.js_on_change(
20
+ "indices",
21
+ CustomJS(
22
+ args=dict(source=cds),
23
+ code="""
24
+ document.dispatchEvent(
25
+ new CustomEvent("YOUR_EVENT_NAME", {detail: {your_data: "goes-here"}})
26
+ )
27
+ """
28
+ )
29
+ )
30
+
31
+ # result will be a dict of {event_name: event.detail}
32
+ # events by default is "", in case of more than one events pass it as a comma separated values
33
+ # event1,event2
34
+ # debounce is in ms
35
+ # refresh_on_update should be set to False only if we dont want to update datasource at runtime
36
+ # override_height overrides the viewport height
37
+ result = streamlit_bokeh_events(
38
+ bokeh_plot=p,
39
+ events="YOUR_EVENT_NAME",
40
+ key="foo",
41
+ refresh_on_update=False,
42
+ override_height=600,
43
+ debounce_time=500)
44
+
45
+ # use the result
46
+ st.write(result)
pages/Cropper.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_cropper import st_cropper
3
+ from PIL import Image
4
+ st.set_option('deprecation.showfileUploaderEncoding', False)
5
+
6
+ # Upload an image and set some options for demo purposes
7
+ st.header("Cropper Demo")
8
+ img_file = st.sidebar.file_uploader(label='Upload a file', type=['png', 'jpg'])
9
+ realtime_update = st.sidebar.checkbox(label="Update in Real Time", value=True)
10
+ box_color = st.sidebar.color_picker(label="Box Color", value='#0000FF')
11
+ aspect_choice = st.sidebar.radio(label="Aspect Ratio", options=["1:1", "16:9", "4:3", "2:3", "Free"])
12
+ aspect_dict = {
13
+ "1:1": (1, 1),
14
+ "16:9": (16, 9),
15
+ "4:3": (4, 3),
16
+ "2:3": (2, 3),
17
+ "Free": None
18
+ }
19
+ aspect_ratio = aspect_dict[aspect_choice]
20
+
21
+ if img_file:
22
+ img = Image.open(img_file)
23
+ if not realtime_update:
24
+ st.write("Double click to save crop")
25
+ # Get a cropped image from the frontend
26
+ cropped_img = st_cropper(img, realtime_update=realtime_update, box_color=box_color,
27
+ aspect_ratio=aspect_ratio)
28
+
29
+ # Manipulate cropped image at will
30
+ st.write("Preview")
31
+ _ = cropped_img.thumbnail((150,150))
32
+ st.image(cropped_img)
pages/D3_Demo.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import random
2
+ from streamlit_d3_demo import d3_line
3
+
4
+ def generate_random_data(x_r, y_r):
5
+ return list(zip(range(x_r), [random.randint(0, y_r) for _ in range(x_r)]))
6
+
7
+ d3_line(generate_random_data(20, 500), circle_radius=15, circle_color="#6495ed")
pages/Discourse.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from streamlit_discourse import st_discourse
2
+
3
+ # https://discuss.streamlit.io/t/discourse-component/8061
4
+
5
+ discourse_url = "discuss.streamlit.io"
6
+ topic_id = 8061
7
+
8
+ st_discourse(discourse_url, topic_id)
pages/Disqus.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from streamlit_disqus import st_disqus
2
+
3
+ st_disqus("streamlit-disqus-demo")
pages/Drawable_Canvas.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from PIL import Image
3
+ import streamlit as st
4
+ from streamlit_drawable_canvas import st_canvas
5
+
6
+ # Specify canvas parameters in application
7
+ drawing_mode = st.sidebar.selectbox(
8
+ "Drawing tool:", ("point", "freedraw", "line", "rect", "circle", "transform")
9
+ )
10
+
11
+ stroke_width = st.sidebar.slider("Stroke width: ", 1, 25, 3)
12
+ if drawing_mode == 'point':
13
+ point_display_radius = st.sidebar.slider("Point display radius: ", 1, 25, 3)
14
+ stroke_color = st.sidebar.color_picker("Stroke color hex: ")
15
+ bg_color = st.sidebar.color_picker("Background color hex: ", "#eee")
16
+ bg_image = st.sidebar.file_uploader("Background image:", type=["png", "jpg"])
17
+
18
+ realtime_update = st.sidebar.checkbox("Update in realtime", True)
19
+
20
+
21
+
22
+ # Create a canvas component
23
+ canvas_result = st_canvas(
24
+ fill_color="rgba(255, 165, 0, 0.3)", # Fixed fill color with some opacity
25
+ stroke_width=stroke_width,
26
+ stroke_color=stroke_color,
27
+ background_color=bg_color,
28
+ background_image=Image.open(bg_image) if bg_image else None,
29
+ update_streamlit=realtime_update,
30
+ height=150,
31
+ drawing_mode=drawing_mode,
32
+ point_display_radius=point_display_radius if drawing_mode == 'point' else 0,
33
+ key="canvas",
34
+ )
35
+
36
+ # Do something interesting with the image data and paths
37
+ if canvas_result.image_data is not None:
38
+ st.image(canvas_result.image_data)
39
+ if canvas_result.json_data is not None:
40
+ objects = pd.json_normalize(canvas_result.json_data["objects"]) # need to convert obj to str because PyArrow
41
+ for col in objects.select_dtypes(include=['object']).columns:
42
+ objects[col] = objects[col].astype("str")
43
+ st.dataframe(objects)
pages/Echarts.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from streamlit_echarts import st_echarts
2
+
3
+ options = {
4
+ "xAxis": {
5
+ "type": "category",
6
+ "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
7
+ },
8
+ "yAxis": {"type": "value"},
9
+ "series": [
10
+ {"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "line"}
11
+ ],
12
+ }
13
+ st_echarts(options=options)
pages/Elements.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # First, import the elements you need
2
+
3
+ from streamlit_elements import elements, mui, html
4
+
5
+ # Create a frame where Elements widgets will be displayed.
6
+ #
7
+ # Elements widgets will not render outside of this frame.
8
+ # Native Streamlit widgets will not render inside this frame.
9
+ #
10
+ # elements() takes a key as parameter.
11
+ # This key can't be reused by another frame or Streamlit widget.
12
+
13
+ with elements("new_element"):
14
+
15
+ # Let's create a Typography element with "Hello world" as children.
16
+ # The first step is to check Typography's documentation on MUI:
17
+ # https://mui.com/components/typography/
18
+ #
19
+ # Here is how you would write it in React JSX:
20
+ #
21
+ # <Typography>
22
+ # Hello world
23
+ # </Typography>
24
+
25
+ mui.Typography("Hello world")
pages/Embedcode.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_embedcode import github_gist
3
+
4
+ github_gist("https://gist.github.com/randyzwitch/be8c5e9fb5b8e7b046afebcac12e5087/")
pages/Extras.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from streamlit_extras.stoggle import stoggle
2
+
3
+ stoggle(
4
+ "Click me!",
5
+ """🥷 Surprise! Here's some additional content""",
6
+ )
pages/Folium.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This sample code has been copied from
3
+ https://github.com/randyzwitch/streamlit-folium/blob/master/examples/streamlit_app.py
4
+ """
5
+
6
+ import streamlit as st
7
+
8
+ st.set_page_config(page_title="streamlit-folium documentation")
9
+
10
+ page = st.sidebar.radio(
11
+ "Select page", ["Home", "Bi-directional data model", "Plugin: Draw"], index=0
12
+ )
13
+
14
+ "# streamlit-folium"
15
+
16
+ if page == "Home":
17
+ "streamlit-folium integrates two great open-source projects in the Python ecosystem: [Streamlit](https://streamlit.io) and [Folium](https://python-visualization.github.io/folium/)!"
18
+
19
+ """
20
+ Currently, there are two functions defined:
21
+
22
+ - `st_folium()`: a bi-directional Component, taking a Folium/Branca object and plotting to the Streamlit app. Upon mount/interaction with the Streamlit app, st_folium() returns a Dict with selected information including the bounding box and items clicked on
23
+
24
+ - `folium_static()`: takes a folium.Map, folium.Figure, or branca.element.Figure object and displays it in a Streamlit app.
25
+
26
+ _Note: `folium_static()` is based on the `_repr_html()` representation created in Folium. This function should be a strict subset the of functionality of the newer `st_folium()` function._
27
+
28
+ It is recommended that users switch to `st_folium()` as soon as possible, as `folium_static()` will likely be deprecated. If there is a reason why `folium_static()` needs to remain, please leave a [GitHub issue](https://github.com/randyzwitch/streamlit-folium/issues) describing your use-case.
29
+ """
30
+
31
+
32
+ "---"
33
+ "### Basic `st_folium()` Example"
34
+
35
+ with st.echo():
36
+
37
+ import streamlit as st
38
+ from streamlit_folium import st_folium
39
+ import folium
40
+
41
+ # center on Liberty Bell, add marker
42
+ m = folium.Map(location=[39.949610, -75.150282], zoom_start=16)
43
+ folium.Marker(
44
+ [39.949610, -75.150282],
45
+ popup="Liberty Bell",
46
+ tooltip="Liberty Bell"
47
+ ).add_to(m)
48
+
49
+ # call to render Folium map in Streamlit
50
+ st_data = st_folium(m, width = 725)
51
+
52
+ elif page == "Bi-directional data model":
53
+ """
54
+ On its own, Folium is limited to _display-only_ visualizations; the Folium API generates the proper [leaflet.js](https://leafletjs.com/) specification,
55
+ as HTML and displays it. Some interactivity is provided (depending on how the Folium API is utilized), but the biggest drawback
56
+ is that the interactivity from the visualization isn't passed back to Python, and as such, you can't make full use of the functionality
57
+ provided by the leaflet.js library.
58
+
59
+ `streamlit-folium` builds upon the convenient [Folium API](https://python-visualization.github.io/folium/modules.html)
60
+ for building geospatial visualizations by adding a _bi-directional_ data transfer functionality. This not only allows for increased interactivity between
61
+ the web browser and Python, but also the use of larger datasets through intelligent querying.
62
+
63
+ ### Bi-directional data model
64
+
65
+ If we take a look at the example from the Home page, it might seem trivial. We define a single point with a marker and pop-up and display it:
66
+ """
67
+ with st.echo():
68
+
69
+ import streamlit as st
70
+ from streamlit_folium import st_folium
71
+ import folium
72
+
73
+ # center on Liberty Bell, add marker
74
+ m = folium.Map(location=[39.949610, -75.150282], zoom_start=16)
75
+ folium.Marker(
76
+ [39.949610, -75.150282],
77
+ popup="Liberty Bell",
78
+ tooltip="Liberty Bell"
79
+ ).add_to(m)
80
+
81
+ # call to render Folium map in Streamlit
82
+ st_data = st_folium(m, width = 725)
83
+
84
+ """
85
+ But behind the scenes, a lot more is happening _by default_. The return value of `st_folium` is set to
86
+ `st_data`, and within this Python variable is information about what is being displayed on the screen:
87
+ """
88
+
89
+ with st.expander("Expand to see data returned to Python"):
90
+ st_data
91
+
92
+ """
93
+ As the user interacts with the data visualization, the values for `bounds` are constantly updating, along
94
+ with `zoom`. With these values available in Python, we can now limit queries based on bounding box, change
95
+ the marker size based on the `zoom` value and much more!
96
+ """
97
+
98
+ elif page == "Plugin: Draw":
99
+
100
+ """
101
+ Folium supports some of the [most popular leaflet plugins](https://python-visualization.github.io/folium/plugins.html). In this example,
102
+ we can add the [`Draw`](https://python-visualization.github.io/folium/plugins.html#folium.plugins.Draw) plugin to our map, which allows for drawing geometric shapes on the map.
103
+
104
+ When a shape is drawn on the map, the coordinates that represent that shape are passed back as a geojson feature via
105
+ the `all_drawings` and `last_active_drawing` data fields.
106
+
107
+ Draw something below to see the return value back to Streamlit!
108
+ """
109
+
110
+ with st.echo():
111
+
112
+ import folium
113
+ import streamlit as st
114
+ from folium.plugins import Draw
115
+ from streamlit_folium import st_folium
116
+
117
+ m = folium.Map(location=[39.949610, -75.150282], zoom_start=5)
118
+ Draw(export=True).add_to(m)
119
+
120
+ c1, c2 = st.columns(2)
121
+ with c1:
122
+ output = st_folium(m, width = 700, height=500)
123
+
124
+ with c2:
125
+ st.write(output)
pages/HiPlot.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This sample code has been copied from
3
+ https://facebookresearch.github.io/hiplot/tuto_streamlit.html
4
+ """
5
+
6
+ import json
7
+ import streamlit as st
8
+ import hiplot as hip
9
+
10
+ x1, x2, x3 = st.slider('x1'), st.slider('x2'), st.slider('x3')
11
+
12
+ # Create your experiment as usual
13
+ data = [{'uid': 'a', 'dropout': 0.1, 'lr': 0.001, 'loss': 10.0, 'optimizer': 'SGD', 'x': x1},
14
+ {'uid': 'b', 'dropout': 0.15, 'lr': 0.01, 'loss': 3.5, 'optimizer': 'Adam', 'x': x2},
15
+ {'uid': 'c', 'dropout': 0.3, 'lr': 0.1, 'loss': 4.5, 'optimizer': 'Adam', 'x': x3}]
16
+ xp = hip.Experiment.from_iterable(data)
17
+
18
+ # Instead of calling directly \`.display()\`
19
+ # just convert it to a streamlit component with \`.to_streamlit()\` before
20
+ ret_val = xp.to_streamlit(ret="selected_uids", key="hip").display()
21
+
22
+ st.markdown("hiplot returned " + json.dumps(ret_val))
pages/Lottie.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import requests
3
+
4
+ import streamlit as st
5
+ from streamlit_lottie import st_lottie
6
+ from streamlit_lottie import st_lottie_spinner
7
+
8
+
9
+ def load_lottieurl(url: str):
10
+ r = requests.get(url)
11
+ if r.status_code != 200:
12
+ return None
13
+ return r.json()
14
+
15
+
16
+ lottie_url_hello = "https://assets5.lottiefiles.com/packages/lf20_V9t630.json"
17
+ lottie_url_download = "https://assets4.lottiefiles.com/private_files/lf30_t26law.json"
18
+ lottie_hello = load_lottieurl(lottie_url_hello)
19
+ lottie_download = load_lottieurl(lottie_url_download)
20
+
21
+
22
+ st_lottie(lottie_hello, key="hello")
23
+
24
+ if st.button("Download"):
25
+ with st_lottie_spinner(lottie_download, key="download"):
26
+ time.sleep(5)
27
+ st.balloons()
pages/Observable.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_observable import observable
3
+
4
+ a = st.slider("Alex", value=30)
5
+ b = st.slider("Brian", value=20)
6
+ c = st.slider("Craig", value=50)
7
+
8
+ observable("Example Updatable Bar Chart",
9
+ notebook="@juba/updatable-bar-chart",
10
+ targets=["chart", "draw"],
11
+ redefine={
12
+ "data": [
13
+ {"name": "Alex", "value": a},
14
+ {"name": "Brian", "value": b},
15
+ {"name": "Craig", "value": c}
16
+ ],
17
+ },
18
+ hide=["draw"]
19
+ )
pages/On_Hover_Tabs.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from st_on_hover_tabs import on_hover_tabs
2
+ import streamlit as st
3
+ st.set_page_config(layout="wide")
4
+
5
+ st.header("Custom tab component for on-hover navigation bar")
6
+ st.markdown('<style>' + open('./style.css').read() + '</style>', unsafe_allow_html=True)
7
+
8
+
9
+ with st.sidebar:
10
+ tabs = on_hover_tabs(tabName=['Dashboard', 'Money', 'Economy'],
11
+ iconName=['dashboard', 'money', 'economy'], default_choice=0)
12
+
13
+ if tabs =='Dashboard':
14
+ st.title("Navigation Bar")
15
+ st.write('Name of option is {}'.format(tabs))
16
+
17
+ elif tabs == 'Money':
18
+ st.title("Paper")
19
+ st.write('Name of option is {}'.format(tabs))
20
+
21
+ elif tabs == 'Economy':
22
+ st.title("Tom")
23
+ st.write('Name of option is {}'.format(tabs))
pages/Option_Menu.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+
4
+ # 1. as sidebar menu
5
+ with st.sidebar:
6
+ selected = option_menu("Main Menu", ["Home", 'Settings'],
7
+ icons=['house', 'gear'], menu_icon="cast", default_index=1)
8
+ selected
9
+
10
+ # 2. horizontal menu
11
+ selected2 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
12
+ icons=['house', 'cloud-upload', "list-task", 'gear'],
13
+ menu_icon="cast", default_index=0, orientation="horizontal")
14
+ selected2
15
+
16
+ # 3. CSS style definitions
17
+ selected3 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
18
+ icons=['house', 'cloud-upload', "list-task", 'gear'],
19
+ menu_icon="cast", default_index=0, orientation="horizontal",
20
+ styles={
21
+ "container": {"padding": "0!important", "background-color": "#fafafa"},
22
+ "icon": {"color": "orange", "font-size": "25px"},
23
+ "nav-link": {"font-size": "25px", "text-align": "left", "margin":"0px", "--hover-color": "#eee"},
24
+ "nav-link-selected": {"background-color": "green"},
25
+ }
26
+ )
pages/Pandas_Profiling.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import pandas_profiling
3
+ import streamlit as st
4
+
5
+ from streamlit_pandas_profiling import st_profile_report
6
+
7
+ df = pd.read_csv("https://storage.googleapis.com/tf-datasets/titanic/train.csv")
8
+ pr = df.profile_report()
9
+
10
+ st_profile_report(pr)
pages/Player.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from streamlit_player import st_player
2
+
3
+ # Embed a youtube video
4
+ st_player("https://youtu.be/CmSKVW1v0xM")
5
+
6
+ # Embed a music from SoundCloud
7
+ st_player("https://soundcloud.com/imaginedragons/demons")
pages/Tags.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from streamlit_tags import st_tags, st_tags_sidebar
2
+
3
+ keywords = st_tags(
4
+ label='# Enter Keywords:',
5
+ text='Press enter to add more',
6
+ value=['Zero', 'One', 'Two'],
7
+ suggestions=['five', 'six', 'seven',
8
+ 'eight', 'nine', 'three',
9
+ 'eleven', 'ten', 'four'],
10
+ maxtags = 4,
11
+ key='1')
12
+
13
+ keyword = st_tags_sidebar(
14
+ label='# Enter Keywords:',
15
+ text='Press enter to add more',
16
+ value=['Zero', 'One', 'Two'],
17
+ suggestions=['five', 'six', 'seven',
18
+ 'eight', 'nine', 'three',
19
+ 'eleven', 'ten', 'four'],
20
+ maxtags = 4,
21
+ key='2')
pages/Vega-Lite.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import altair as alt
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+ from streamlit_vega_lite import vega_lite_component, altair_component
7
+
8
+ hist_data = pd.DataFrame(np.random.normal(42, 10, (200, 1)), columns=["x"])
9
+
10
+ @st.cache
11
+ def altair_histogram():
12
+ brushed = alt.selection_interval(encodings=["x"], name="brushed")
13
+
14
+ return (
15
+ alt.Chart(hist_data)
16
+ .mark_bar()
17
+ .encode(alt.X("x:Q", bin=True), y="count()")
18
+ .add_selection(brushed)
19
+ )
20
+
21
+ event_dict = altair_component(altair_chart=altair_histogram())
22
+
23
+ r = event_dict.get("x")
24
+ if r:
25
+ filtered = hist_data[(hist_data.x >= r[0]) & (hist_data.x < r[1])]
26
+ st.write(filtered)
pages/WebRTC.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from streamlit_webrtc import webrtc_streamer
2
+
3
+ webrtc_streamer(key="sample")
pages/spaCy.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copied from https://github.com/explosion/spacy-streamlit/blob/master/examples/01_out-of-the-box.py
2
+ """
3
+ Very basic out-of-the-box example using the full visualizer. This file can be
4
+ run using the "streamlit run" command.
5
+ Prerequisites:
6
+ python -m spacy download en_core_web_sm
7
+ python -m spacy download en_core_web_md
8
+ """
9
+ import spacy_streamlit
10
+
11
+ models = ["en_core_web_sm", "en_core_web_md"]
12
+ default_text = "Sundar Pichai is the CEO of Google."
13
+ spacy_streamlit.visualize(models, default_text)
requirements.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ stmol
2
+ py3Dmol==2.0.0.post2
3
+ streamlit-ace
4
+ streamlit-aggrid
5
+ streamlit-agraph
6
+ streamlit-analytics
7
+ st-annotated-text
8
+ streamlit-authenticator
9
+ streamlit-bokeh-events
10
+ streamlit-cropper
11
+ streamlit-d3-demo
12
+ streamlit-discourse
13
+ streamlit-disqus
14
+ streamlit-drawable-canvas
15
+ streamlit-echarts
16
+ streamlit-elements
17
+ streamlit-embedcode
18
+ streamlit-extras
19
+ streamlit-folium
20
+ hiplot
21
+ streamlit-lottie
22
+ streamlit-observable
23
+ streamlit-on-Hover-tabs
24
+ streamlit-option-menu
25
+ streamlit-pandas-profiling
26
+ streamlit-player
27
+ spacy-streamlit
28
+ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
29
+ https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.5.0/en_core_web_md-3.5.0-py3-none-any.whl
30
+ streamlit-tags
31
+ streamlit-vega-lite
32
+ streamlit-webrtc
style.css ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ section[data-testid='stSidebar'] {
2
+ background-color: #111;
3
+ min-width:unset !important;
4
+ width: unset !important;
5
+ flex-shrink: unset !important;
6
+
7
+ }
8
+
9
+ button[kind="header"] {
10
+ background-color: transparent;
11
+ color:rgb(180, 167, 141)
12
+ }
13
+
14
+ @media(hover){
15
+ /* header element to be removed */
16
+ header[data-testid="stHeader"] {
17
+ display:none;
18
+ }
19
+
20
+ /* The navigation menu specs and size */
21
+ section[data-testid='stSidebar'] > div {
22
+ height: 100%;
23
+ width: 95px;
24
+ position: relative;
25
+ z-index: 1;
26
+ top: 0;
27
+ left: 0;
28
+ background-color: #111;
29
+ overflow-x: hidden;
30
+ transition: 0.5s ease;
31
+ padding-top: 60px;
32
+ white-space: nowrap;
33
+ }
34
+
35
+ /* The navigation menu open and close on hover and size */
36
+ /* section[data-testid='stSidebar'] > div {
37
+ height: 100%;
38
+ width: 75px; /* Put some width to hover on. */
39
+ /* }
40
+
41
+ /* ON HOVER */
42
+ section[data-testid='stSidebar'] > div:hover{
43
+ width: 300px;
44
+ }
45
+
46
+ /* The button on the streamlit navigation menu - hidden */
47
+ button[kind="header"] {
48
+ display: none;
49
+ }
50
+ }
51
+
52
+ @media(max-width: 272px){
53
+
54
+ section[data-testid='stSidebar'] > div {
55
+ width:15rem;
56
+ }
57
+ }
58
+