streamlit-node-editor 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit_node_editor-0.1.0/LICENSE +21 -0
- streamlit_node_editor-0.1.0/MANIFEST.in +1 -0
- streamlit_node_editor-0.1.0/PKG-INFO +217 -0
- streamlit_node_editor-0.1.0/README.md +192 -0
- streamlit_node_editor-0.1.0/setup.cfg +4 -0
- streamlit_node_editor-0.1.0/setup.py +21 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/__init__.py +120 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/frontend/build/asset-manifest.json +10 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/frontend/build/index.html +1 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/frontend/build/static/js/main.9884c600.js +3 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/frontend/build/static/js/main.9884c600.js.LICENSE.txt +63 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor/frontend/build/static/js/main.9884c600.js.map +1 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor.egg-info/PKG-INFO +217 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor.egg-info/SOURCES.txt +15 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor.egg-info/dependency_links.txt +1 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor.egg-info/requires.txt +1 -0
- streamlit_node_editor-0.1.0/streamlit_node_editor.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include streamlit_node_editor/frontend/build *
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamlit-node-editor
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A ComfyUI/Blueprints-style node graph editor for Streamlit — typed ports, drag-to-connect, inline params
|
|
5
|
+
Home-page: https://github.com/RhythrosaLabs/streamlit-node-editor
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: you@example.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: streamlit>=1.28.0
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# streamlit-node-editor
|
|
27
|
+
|
|
28
|
+
A ComfyUI / Unreal Blueprints-style node graph editor for Streamlit. Define typed node types in Python, let users build graphs by dragging ports and connecting nodes, and get the full graph state back as structured JSON.
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Typed ports** with color-coded data types — only compatible types can connect
|
|
35
|
+
- **Drag-to-wire** — click an output port, drag, drop on a compatible input to create a connection
|
|
36
|
+
- **Type validation** — incompatible connections are silently rejected
|
|
37
|
+
- **Inline node parameters** — select dropdowns, number inputs, text inputs, and textareas inside each node
|
|
38
|
+
- **Node palette** — searchable list of all available node types; right-click canvas or use toolbar button
|
|
39
|
+
- **Click wire to delete** — no menu needed
|
|
40
|
+
- **Delete / Backspace** removes the selected node and all its connections
|
|
41
|
+
- **Collapse nodes** to save canvas space
|
|
42
|
+
- **Pan + scroll-to-zoom** with proper SVG coordinate transform
|
|
43
|
+
- **Animated dot-grid background**
|
|
44
|
+
- Zero runtime dependencies beyond Streamlit (no React Flow, no external graph lib)
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install streamlit-node-editor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quickstart — data pipeline builder
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import streamlit as st
|
|
56
|
+
from streamlit_node_editor import st_node_editor
|
|
57
|
+
|
|
58
|
+
NODE_DEFS = {
|
|
59
|
+
"CSV Source": {
|
|
60
|
+
"category": "Sources",
|
|
61
|
+
"headerColor": "#4ade80",
|
|
62
|
+
"inputs": [],
|
|
63
|
+
"outputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
64
|
+
"params": [
|
|
65
|
+
{"key": "path", "label": "File path", "type": "string", "default": "data.csv"},
|
|
66
|
+
{"key": "sep", "label": "Separator", "type": "string", "default": ","},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
"Filter Rows": {
|
|
70
|
+
"category": "Transform",
|
|
71
|
+
"headerColor": "#38bdf8",
|
|
72
|
+
"inputs": [{"name": "df_in", "type": "DATAFRAME"}],
|
|
73
|
+
"outputs": [{"name": "df_out", "type": "DATAFRAME"}],
|
|
74
|
+
"params": [
|
|
75
|
+
{"key": "query", "label": "Query expr", "type": "string",
|
|
76
|
+
"default": "value > 0"},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
"Group By": {
|
|
80
|
+
"category": "Transform",
|
|
81
|
+
"headerColor": "#818cf8",
|
|
82
|
+
"inputs": [{"name": "df_in", "type": "DATAFRAME"}],
|
|
83
|
+
"outputs": [{"name": "df_out", "type": "DATAFRAME"}],
|
|
84
|
+
"params": [
|
|
85
|
+
{"key": "column", "label": "Column", "type": "string"},
|
|
86
|
+
{"key": "agg", "label": "Aggregate","type": "select",
|
|
87
|
+
"options": ["sum", "mean", "count", "min", "max"]},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
"Bar Chart": {
|
|
91
|
+
"category": "Outputs",
|
|
92
|
+
"headerColor": "#fb923c",
|
|
93
|
+
"inputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
94
|
+
"outputs": [],
|
|
95
|
+
"params": [
|
|
96
|
+
{"key": "x", "label": "X column", "type": "string"},
|
|
97
|
+
{"key": "y", "label": "Y column", "type": "string"},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
graph = st_node_editor(NODE_DEFS, height=600, key="pipeline")
|
|
103
|
+
|
|
104
|
+
if graph:
|
|
105
|
+
st.subheader("Graph state")
|
|
106
|
+
st.json(graph)
|
|
107
|
+
|
|
108
|
+
# Execute the pipeline
|
|
109
|
+
if st.button("Run pipeline"):
|
|
110
|
+
import pandas as pd
|
|
111
|
+
# Walk graph["connections"] in topological order and execute each node
|
|
112
|
+
# based on graph["nodes"][i]["type"] and graph["nodes"][i]["params"]
|
|
113
|
+
st.info("Pipeline execution logic goes here")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
st_node_editor(node_defs, initial_nodes=None, initial_connections=None, height=700, key=None)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Parameter | Type | Default | Description |
|
|
123
|
+
|-----------|------|---------|-------------|
|
|
124
|
+
| `node_defs` | `dict[str, dict]` | required | Node type registry |
|
|
125
|
+
| `initial_nodes` | `list[dict]` | `[]` | Pre-placed nodes |
|
|
126
|
+
| `initial_connections` | `list[dict]` | `[]` | Pre-existing wires |
|
|
127
|
+
| `height` | `int` | `700` | Canvas height in pixels |
|
|
128
|
+
| `key` | `str` | `None` | Streamlit widget key |
|
|
129
|
+
|
|
130
|
+
### Node definition schema
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
"Node Type Name": {
|
|
134
|
+
"category": str, # palette grouping
|
|
135
|
+
"headerColor": str, # hex color for the node's title bar
|
|
136
|
+
"inputs": [
|
|
137
|
+
{"name": str, "type": str} # type key must match a registered port type
|
|
138
|
+
],
|
|
139
|
+
"outputs": [
|
|
140
|
+
{"name": str, "type": str}
|
|
141
|
+
],
|
|
142
|
+
"params": [
|
|
143
|
+
{
|
|
144
|
+
"key": str,
|
|
145
|
+
"label": str,
|
|
146
|
+
"type": str, # "int" | "float" | "string" | "select" | "textarea"
|
|
147
|
+
"default": any, # optional
|
|
148
|
+
"options": list[str], # required when type == "select"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Built-in port types
|
|
155
|
+
|
|
156
|
+
| Type | Color | Typical use |
|
|
157
|
+
|------|-------|-------------|
|
|
158
|
+
| `IMAGE` | green | Pixel data |
|
|
159
|
+
| `LATENT` | purple | Latent tensors |
|
|
160
|
+
| `MODEL` | orange | Neural network weights |
|
|
161
|
+
| `CLIP` | yellow | Text encoders |
|
|
162
|
+
| `VAE` | red | Variational autoencoders |
|
|
163
|
+
| `INT` | blue | Integer values |
|
|
164
|
+
| `FLOAT` | indigo | Float values |
|
|
165
|
+
| `STRING` | stone | Text |
|
|
166
|
+
| `MASK` | teal | Binary masks |
|
|
167
|
+
| `ANY` | gray | Accepts any type |
|
|
168
|
+
|
|
169
|
+
Define your own types freely in `node_defs` — any unrecognized type string uses the `ANY` gray color.
|
|
170
|
+
|
|
171
|
+
### Return value
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
{
|
|
175
|
+
"nodes": [
|
|
176
|
+
{
|
|
177
|
+
"id": str,
|
|
178
|
+
"type": str,
|
|
179
|
+
"x": float,
|
|
180
|
+
"y": float,
|
|
181
|
+
"params": {key: value, ...}
|
|
182
|
+
},
|
|
183
|
+
...
|
|
184
|
+
],
|
|
185
|
+
"connections": [
|
|
186
|
+
{
|
|
187
|
+
"id": str,
|
|
188
|
+
"fromNode": str, # node id
|
|
189
|
+
"fromPort": int, # output port index
|
|
190
|
+
"toNode": str, # node id
|
|
191
|
+
"toPort": int, # input port index
|
|
192
|
+
},
|
|
193
|
+
...
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
git clone https://github.com/RhythrosaLabs/streamlit-node-editor
|
|
202
|
+
cd streamlit-node-editor
|
|
203
|
+
|
|
204
|
+
cd streamlit_node_editor/frontend
|
|
205
|
+
npm install
|
|
206
|
+
npm start # dev server on :3004
|
|
207
|
+
|
|
208
|
+
# separate terminal
|
|
209
|
+
cd ../..
|
|
210
|
+
pip install -e .
|
|
211
|
+
# Set _RELEASE = False in streamlit_node_editor/__init__.py
|
|
212
|
+
streamlit run example.py
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
MIT
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# streamlit-node-editor
|
|
2
|
+
|
|
3
|
+
A ComfyUI / Unreal Blueprints-style node graph editor for Streamlit. Define typed node types in Python, let users build graphs by dragging ports and connecting nodes, and get the full graph state back as structured JSON.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Typed ports** with color-coded data types — only compatible types can connect
|
|
10
|
+
- **Drag-to-wire** — click an output port, drag, drop on a compatible input to create a connection
|
|
11
|
+
- **Type validation** — incompatible connections are silently rejected
|
|
12
|
+
- **Inline node parameters** — select dropdowns, number inputs, text inputs, and textareas inside each node
|
|
13
|
+
- **Node palette** — searchable list of all available node types; right-click canvas or use toolbar button
|
|
14
|
+
- **Click wire to delete** — no menu needed
|
|
15
|
+
- **Delete / Backspace** removes the selected node and all its connections
|
|
16
|
+
- **Collapse nodes** to save canvas space
|
|
17
|
+
- **Pan + scroll-to-zoom** with proper SVG coordinate transform
|
|
18
|
+
- **Animated dot-grid background**
|
|
19
|
+
- Zero runtime dependencies beyond Streamlit (no React Flow, no external graph lib)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install streamlit-node-editor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quickstart — data pipeline builder
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import streamlit as st
|
|
31
|
+
from streamlit_node_editor import st_node_editor
|
|
32
|
+
|
|
33
|
+
NODE_DEFS = {
|
|
34
|
+
"CSV Source": {
|
|
35
|
+
"category": "Sources",
|
|
36
|
+
"headerColor": "#4ade80",
|
|
37
|
+
"inputs": [],
|
|
38
|
+
"outputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
39
|
+
"params": [
|
|
40
|
+
{"key": "path", "label": "File path", "type": "string", "default": "data.csv"},
|
|
41
|
+
{"key": "sep", "label": "Separator", "type": "string", "default": ","},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
"Filter Rows": {
|
|
45
|
+
"category": "Transform",
|
|
46
|
+
"headerColor": "#38bdf8",
|
|
47
|
+
"inputs": [{"name": "df_in", "type": "DATAFRAME"}],
|
|
48
|
+
"outputs": [{"name": "df_out", "type": "DATAFRAME"}],
|
|
49
|
+
"params": [
|
|
50
|
+
{"key": "query", "label": "Query expr", "type": "string",
|
|
51
|
+
"default": "value > 0"},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
"Group By": {
|
|
55
|
+
"category": "Transform",
|
|
56
|
+
"headerColor": "#818cf8",
|
|
57
|
+
"inputs": [{"name": "df_in", "type": "DATAFRAME"}],
|
|
58
|
+
"outputs": [{"name": "df_out", "type": "DATAFRAME"}],
|
|
59
|
+
"params": [
|
|
60
|
+
{"key": "column", "label": "Column", "type": "string"},
|
|
61
|
+
{"key": "agg", "label": "Aggregate","type": "select",
|
|
62
|
+
"options": ["sum", "mean", "count", "min", "max"]},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
"Bar Chart": {
|
|
66
|
+
"category": "Outputs",
|
|
67
|
+
"headerColor": "#fb923c",
|
|
68
|
+
"inputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
69
|
+
"outputs": [],
|
|
70
|
+
"params": [
|
|
71
|
+
{"key": "x", "label": "X column", "type": "string"},
|
|
72
|
+
{"key": "y", "label": "Y column", "type": "string"},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
graph = st_node_editor(NODE_DEFS, height=600, key="pipeline")
|
|
78
|
+
|
|
79
|
+
if graph:
|
|
80
|
+
st.subheader("Graph state")
|
|
81
|
+
st.json(graph)
|
|
82
|
+
|
|
83
|
+
# Execute the pipeline
|
|
84
|
+
if st.button("Run pipeline"):
|
|
85
|
+
import pandas as pd
|
|
86
|
+
# Walk graph["connections"] in topological order and execute each node
|
|
87
|
+
# based on graph["nodes"][i]["type"] and graph["nodes"][i]["params"]
|
|
88
|
+
st.info("Pipeline execution logic goes here")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
st_node_editor(node_defs, initial_nodes=None, initial_connections=None, height=700, key=None)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Default | Description |
|
|
98
|
+
|-----------|------|---------|-------------|
|
|
99
|
+
| `node_defs` | `dict[str, dict]` | required | Node type registry |
|
|
100
|
+
| `initial_nodes` | `list[dict]` | `[]` | Pre-placed nodes |
|
|
101
|
+
| `initial_connections` | `list[dict]` | `[]` | Pre-existing wires |
|
|
102
|
+
| `height` | `int` | `700` | Canvas height in pixels |
|
|
103
|
+
| `key` | `str` | `None` | Streamlit widget key |
|
|
104
|
+
|
|
105
|
+
### Node definition schema
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
"Node Type Name": {
|
|
109
|
+
"category": str, # palette grouping
|
|
110
|
+
"headerColor": str, # hex color for the node's title bar
|
|
111
|
+
"inputs": [
|
|
112
|
+
{"name": str, "type": str} # type key must match a registered port type
|
|
113
|
+
],
|
|
114
|
+
"outputs": [
|
|
115
|
+
{"name": str, "type": str}
|
|
116
|
+
],
|
|
117
|
+
"params": [
|
|
118
|
+
{
|
|
119
|
+
"key": str,
|
|
120
|
+
"label": str,
|
|
121
|
+
"type": str, # "int" | "float" | "string" | "select" | "textarea"
|
|
122
|
+
"default": any, # optional
|
|
123
|
+
"options": list[str], # required when type == "select"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Built-in port types
|
|
130
|
+
|
|
131
|
+
| Type | Color | Typical use |
|
|
132
|
+
|------|-------|-------------|
|
|
133
|
+
| `IMAGE` | green | Pixel data |
|
|
134
|
+
| `LATENT` | purple | Latent tensors |
|
|
135
|
+
| `MODEL` | orange | Neural network weights |
|
|
136
|
+
| `CLIP` | yellow | Text encoders |
|
|
137
|
+
| `VAE` | red | Variational autoencoders |
|
|
138
|
+
| `INT` | blue | Integer values |
|
|
139
|
+
| `FLOAT` | indigo | Float values |
|
|
140
|
+
| `STRING` | stone | Text |
|
|
141
|
+
| `MASK` | teal | Binary masks |
|
|
142
|
+
| `ANY` | gray | Accepts any type |
|
|
143
|
+
|
|
144
|
+
Define your own types freely in `node_defs` — any unrecognized type string uses the `ANY` gray color.
|
|
145
|
+
|
|
146
|
+
### Return value
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
{
|
|
150
|
+
"nodes": [
|
|
151
|
+
{
|
|
152
|
+
"id": str,
|
|
153
|
+
"type": str,
|
|
154
|
+
"x": float,
|
|
155
|
+
"y": float,
|
|
156
|
+
"params": {key: value, ...}
|
|
157
|
+
},
|
|
158
|
+
...
|
|
159
|
+
],
|
|
160
|
+
"connections": [
|
|
161
|
+
{
|
|
162
|
+
"id": str,
|
|
163
|
+
"fromNode": str, # node id
|
|
164
|
+
"fromPort": int, # output port index
|
|
165
|
+
"toNode": str, # node id
|
|
166
|
+
"toPort": int, # input port index
|
|
167
|
+
},
|
|
168
|
+
...
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
git clone https://github.com/RhythrosaLabs/streamlit-node-editor
|
|
177
|
+
cd streamlit-node-editor
|
|
178
|
+
|
|
179
|
+
cd streamlit_node_editor/frontend
|
|
180
|
+
npm install
|
|
181
|
+
npm start # dev server on :3004
|
|
182
|
+
|
|
183
|
+
# separate terminal
|
|
184
|
+
cd ../..
|
|
185
|
+
pip install -e .
|
|
186
|
+
# Set _RELEASE = False in streamlit_node_editor/__init__.py
|
|
187
|
+
streamlit run example.py
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="streamlit-node-editor",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
author="Your Name",
|
|
7
|
+
author_email="you@example.com",
|
|
8
|
+
description="A ComfyUI/Blueprints-style node graph editor for Streamlit — typed ports, drag-to-connect, inline params",
|
|
9
|
+
long_description=open("README.md").read(),
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
url="https://github.com/RhythrosaLabs/streamlit-node-editor",
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
include_package_data=True,
|
|
14
|
+
classifiers=[
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
],
|
|
19
|
+
python_requires=">=3.8",
|
|
20
|
+
install_requires=["streamlit>=1.28.0"],
|
|
21
|
+
)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import streamlit.components.v1 as components
|
|
3
|
+
|
|
4
|
+
_RELEASE = True
|
|
5
|
+
|
|
6
|
+
if _RELEASE:
|
|
7
|
+
_component_func = components.declare_component(
|
|
8
|
+
"streamlit_node_editor",
|
|
9
|
+
path=os.path.join(os.path.dirname(__file__), "frontend/build"),
|
|
10
|
+
)
|
|
11
|
+
else:
|
|
12
|
+
_component_func = components.declare_component(
|
|
13
|
+
"streamlit_node_editor",
|
|
14
|
+
url="http://localhost:3001",
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def st_node_editor(node_defs, initial_nodes=None, initial_connections=None,
|
|
19
|
+
height=700, key=None):
|
|
20
|
+
"""
|
|
21
|
+
Render a ComfyUI / Unreal Blueprints-style node graph editor.
|
|
22
|
+
|
|
23
|
+
Users can add nodes from a palette, connect typed ports by dragging,
|
|
24
|
+
edit inline parameters, and delete nodes or wires interactively.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
node_defs : dict[str, dict]
|
|
29
|
+
Registry of available node types. Each entry::
|
|
30
|
+
|
|
31
|
+
"Node Name": {
|
|
32
|
+
"category": str, # groups nodes in the palette
|
|
33
|
+
"headerColor": str, # hex color for the node header bar
|
|
34
|
+
"inputs": [ # list of input port definitions
|
|
35
|
+
{"name": str, "type": str}, # type must be a key in port_types
|
|
36
|
+
],
|
|
37
|
+
"outputs": [ # list of output port definitions
|
|
38
|
+
{"name": str, "type": str},
|
|
39
|
+
],
|
|
40
|
+
"params": [ # inline editable parameters
|
|
41
|
+
{
|
|
42
|
+
"key": str,
|
|
43
|
+
"label": str,
|
|
44
|
+
"type": str, # "int" | "float" | "string" | "select" | "textarea"
|
|
45
|
+
"default": any, # optional default value
|
|
46
|
+
"options": list[str], # required for type="select"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
initial_nodes : list[dict], optional
|
|
52
|
+
Pre-placed nodes on load. Each dict::
|
|
53
|
+
|
|
54
|
+
{"id": str, "type": str, "x": float, "y": float,
|
|
55
|
+
"params": {key: value}}
|
|
56
|
+
|
|
57
|
+
initial_connections : list[dict], optional
|
|
58
|
+
Pre-existing wires. Each dict::
|
|
59
|
+
|
|
60
|
+
{"id": str, "fromNode": str, "fromPort": int,
|
|
61
|
+
"toNode": str, "toPort": int}
|
|
62
|
+
|
|
63
|
+
height : int
|
|
64
|
+
Canvas height in pixels. Default 700.
|
|
65
|
+
key : str, optional
|
|
66
|
+
Streamlit widget key.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
dict | None
|
|
71
|
+
Current graph state::
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
"nodes": [
|
|
75
|
+
{"id": str, "type": str, "x": float, "y": float,
|
|
76
|
+
"params": {key: value}},
|
|
77
|
+
...
|
|
78
|
+
],
|
|
79
|
+
"connections": [
|
|
80
|
+
{"id": str, "fromNode": str, "fromPort": int,
|
|
81
|
+
"toNode": str, "toPort": int},
|
|
82
|
+
...
|
|
83
|
+
],
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Returns None before any interaction.
|
|
87
|
+
|
|
88
|
+
Example
|
|
89
|
+
-------
|
|
90
|
+
>>> from streamlit_node_editor import st_node_editor
|
|
91
|
+
>>>
|
|
92
|
+
>>> NODE_DEFS = {
|
|
93
|
+
... "Load Data": {
|
|
94
|
+
... "category": "Sources",
|
|
95
|
+
... "headerColor": "#4ade80",
|
|
96
|
+
... "inputs": [],
|
|
97
|
+
... "outputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
98
|
+
... "params": [{"key": "path", "label": "CSV path", "type": "string"}],
|
|
99
|
+
... },
|
|
100
|
+
... "Filter Rows": {
|
|
101
|
+
... "category": "Transform",
|
|
102
|
+
... "headerColor": "#38bdf8",
|
|
103
|
+
... "inputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
104
|
+
... "outputs": [{"name": "dataframe", "type": "DATAFRAME"}],
|
|
105
|
+
... "params": [{"key": "query", "label": "Query", "type": "string"}],
|
|
106
|
+
... },
|
|
107
|
+
... }
|
|
108
|
+
>>>
|
|
109
|
+
>>> graph = st_node_editor(NODE_DEFS, height=600, key="pipeline")
|
|
110
|
+
>>> if graph:
|
|
111
|
+
... st.json(graph)
|
|
112
|
+
"""
|
|
113
|
+
return _component_func(
|
|
114
|
+
node_defs=node_defs,
|
|
115
|
+
initial_nodes=initial_nodes or [],
|
|
116
|
+
initial_connections=initial_connections or [],
|
|
117
|
+
height=height,
|
|
118
|
+
key=key,
|
|
119
|
+
default=None,
|
|
120
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Streamlit Node Editor</title><script defer="defer" src="./static/js/main.9884c600.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|