awacke1 commited on
Commit
7174b50
·
1 Parent(s): 8de37dd

Create new file

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from bokeh.models.widgets import Button
3
+ from bokeh.models import CustomJS
4
+ from streamlit_bokeh_events import streamlit_bokeh_events
5
+ import pandas as pd
6
+
7
+ df = pd.DataFrame({"x": [1, 2, 3, 4], "y": ["a", "b", "c", "d"]})
8
+
9
+ st.dataframe(df)
10
+
11
+ copy_button = Button(label="Copy DF")
12
+ copy_button.js_on_event("button_click", CustomJS(args=dict(df=df.to_csv(sep='\t')), code="""
13
+ navigator.clipboard.writeText(df);
14
+ """))
15
+
16
+ no_event = streamlit_bokeh_events(
17
+ copy_button,
18
+ events="GET_TEXT",
19
+ key="get_text",
20
+ refresh_on_update=True,
21
+ override_height=75,
22
+ debounce_time=0)