maom commited on
Commit
0266ad5
·
verified ·
1 Parent(s): eb46832

try example cytoscape-js

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_cytoscapejs import st_cytoscapejs
3
+
4
+ elements = [
5
+ {"data": {"id": "one", "label": "Node 1"}, "position": {"x": 0, "y": 0}},
6
+ {"data": {"id": "two", "label": "Node 2"}, "position": {"x": 100, "y": 0}},
7
+ {"data": {"source": "one", "target": "two", "label": "Edge from Node1 to Node2"}},
8
+ ]
9
+ stylesheet = [
10
+ {"selector": "node", "style": {"width": 20, "height": 20, "shape": "rectangle"}},
11
+ {"selector": "edge", "style": {"width": 10}},
12
+ ]
13
+
14
+ st.title("Hello Cytoscape.js")
15
+ clicked_elements = st_cytoscapejs(elements, stylesheet)
16
+
17
+ if clicked_elements is not None:
18
+ st.write(clicked_elements)