gcc-slycooper50 0.1.128__py3-none-any.whl → 0.1.130__py3-none-any.whl
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.
Potentially problematic release.
This version of gcc-slycooper50 might be problematic. Click here for more details.
- gcc_slycooper50/tree_app.py +272 -0
- {gcc_slycooper50-0.1.128.dist-info → gcc_slycooper50-0.1.130.dist-info}/METADATA +1 -1
- gcc_slycooper50-0.1.130.dist-info/RECORD +6 -0
- gcc_slycooper50/glad-2.0.8.tar.gz +0 -0
- gcc_slycooper50-0.1.128.dist-info/RECORD +0 -6
- {gcc_slycooper50-0.1.128.dist-info → gcc_slycooper50-0.1.130.dist-info}/WHEEL +0 -0
- {gcc_slycooper50-0.1.128.dist-info → gcc_slycooper50-0.1.130.dist-info}/licenses/LICENSE +0 -0
- {gcc_slycooper50-0.1.128.dist-info → gcc_slycooper50-0.1.130.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
from pyvis.network import Network
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
# ---------------------------
|
|
5
|
+
# Tree data
|
|
6
|
+
# ---------------------------
|
|
7
|
+
tree_data = {
|
|
8
|
+
"Root": {"type": "root", "value": 10, "children": ["Child 1", "Child 2", "Child 3"]},
|
|
9
|
+
|
|
10
|
+
"Child 1": {"type": "branch", "value": 5, "children": ["Grandchild 1.1", "Grandchild 1.2"]},
|
|
11
|
+
"Child 2": {"type": "branch", "value": 7, "children": ["Grandchild 2.1", "Grandchild 2.2"]},
|
|
12
|
+
"Child 3": {"type": "branch", "value": 6, "children": ["Grandchild 3.1"]},
|
|
13
|
+
|
|
14
|
+
"Grandchild 1.1": {"type": "leaf", "value": 3, "children": []},
|
|
15
|
+
"Grandchild 1.2": {"type": "leaf", "value": 4, "children": [], "highlight": True},
|
|
16
|
+
|
|
17
|
+
"Grandchild 2.1": {"type": "branch", "value": 2, "children": ["GreatGrandchild 2.1.1"]},
|
|
18
|
+
"Grandchild 2.2": {"type": "leaf", "value": 4, "children": []},
|
|
19
|
+
|
|
20
|
+
"Grandchild 3.1": {"type": "branch", "value": 5, "children": ["GreatGrandchild 3.1.1", "GreatGrandchild 3.1.2"]},
|
|
21
|
+
|
|
22
|
+
"GreatGrandchild 2.1.1": {"type": "leaf", "value": 1, "children": [], "highlight": True},
|
|
23
|
+
"GreatGrandchild 3.1.1": {"type": "leaf", "value": 2, "children": []},
|
|
24
|
+
"GreatGrandchild 3.1.2": {"type": "leaf", "value": 3, "children": [], "highlight": True},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# ---------------------------
|
|
28
|
+
# Positions for layout (x,y)
|
|
29
|
+
# ---------------------------
|
|
30
|
+
positions = {
|
|
31
|
+
"Root": (0, 0),
|
|
32
|
+
"Child 1": (-300, 150),
|
|
33
|
+
"Child 2": (0, 150),
|
|
34
|
+
"Child 3": (300, 150),
|
|
35
|
+
|
|
36
|
+
"Grandchild 1.1": (-400, 300),
|
|
37
|
+
"Grandchild 1.2": (-200, 300),
|
|
38
|
+
|
|
39
|
+
"Grandchild 2.1": (-50, 300),
|
|
40
|
+
"Grandchild 2.2": (50, 300),
|
|
41
|
+
|
|
42
|
+
"Grandchild 3.1": (300, 300),
|
|
43
|
+
|
|
44
|
+
"GreatGrandchild 2.1.1": (-50, 450),
|
|
45
|
+
"GreatGrandchild 3.1.1": (250, 450),
|
|
46
|
+
"GreatGrandchild 3.1.2": (350, 450),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
colors = {"root": "#ffcc00", "branch": "#66ccff", "leaf": "#99ff99"}
|
|
50
|
+
|
|
51
|
+
# ---------------------------
|
|
52
|
+
# Build Pyvis Network
|
|
53
|
+
# ---------------------------
|
|
54
|
+
#net = Network(height="600px", width="100%", directed=True, notebook=False)
|
|
55
|
+
|
|
56
|
+
net = Network(
|
|
57
|
+
height="600px",
|
|
58
|
+
width="100%",
|
|
59
|
+
directed=True,
|
|
60
|
+
notebook=False,
|
|
61
|
+
cdn_resources='remote' # <-- load JS via CDN, avoids utils.js errors
|
|
62
|
+
)
|
|
63
|
+
net.toggle_physics(False)
|
|
64
|
+
|
|
65
|
+
for name, props in tree_data.items():
|
|
66
|
+
x, y = positions[name]
|
|
67
|
+
node_color = "red" if props.get("highlight") else colors[props["type"]]
|
|
68
|
+
net.add_node(name, label=name, x=x, y=y, fixed=False, color=node_color, size=25)
|
|
69
|
+
|
|
70
|
+
for parent, props in tree_data.items():
|
|
71
|
+
for child in props["children"]:
|
|
72
|
+
net.add_edge(parent, child, arrows='to', smooth={'type': 'cubicBezier', 'roundness': 0.4})
|
|
73
|
+
|
|
74
|
+
# Generate HTML
|
|
75
|
+
html = net.generate_html()
|
|
76
|
+
|
|
77
|
+
# ---------------------------
|
|
78
|
+
# Extra sidebar JS/CSS
|
|
79
|
+
# ---------------------------
|
|
80
|
+
extra_js = f"""
|
|
81
|
+
<style>
|
|
82
|
+
#sidebar {{
|
|
83
|
+
position: absolute;
|
|
84
|
+
left: 10px;
|
|
85
|
+
top: 10px;
|
|
86
|
+
width: 250px;
|
|
87
|
+
background: #f8f8f8;
|
|
88
|
+
padding: 10px;
|
|
89
|
+
border-radius: 10px;
|
|
90
|
+
box-shadow: 0 0 8px rgba(0,0,0,0.2);
|
|
91
|
+
font-family: Arial;
|
|
92
|
+
}}
|
|
93
|
+
#menuBar button {{
|
|
94
|
+
margin: 3px;
|
|
95
|
+
padding: 5px 8px;
|
|
96
|
+
border: none;
|
|
97
|
+
background: #ddd;
|
|
98
|
+
border-radius: 4px;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}}
|
|
101
|
+
#menuBar button:hover {{
|
|
102
|
+
background: #ccc;
|
|
103
|
+
}}
|
|
104
|
+
#expandMenu {{
|
|
105
|
+
display: none;
|
|
106
|
+
position: absolute;
|
|
107
|
+
background: white;
|
|
108
|
+
border: 1px solid #aaa;
|
|
109
|
+
box-shadow: 0 0 5px rgba(0,0,0,0.2);
|
|
110
|
+
border-radius: 5px;
|
|
111
|
+
padding: 5px;
|
|
112
|
+
margin-top: 5px;
|
|
113
|
+
z-index: 1000;
|
|
114
|
+
}}
|
|
115
|
+
#expandMenu div {{
|
|
116
|
+
padding: 5px;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
}}
|
|
119
|
+
#expandMenu div:hover {{
|
|
120
|
+
background: #eee;
|
|
121
|
+
}}
|
|
122
|
+
#saveButton {{
|
|
123
|
+
width: 100%;
|
|
124
|
+
margin-top: 10px;
|
|
125
|
+
padding: 8px;
|
|
126
|
+
border: none;
|
|
127
|
+
background: #4CAF50;
|
|
128
|
+
color: white;
|
|
129
|
+
font-weight: bold;
|
|
130
|
+
border-radius: 6px;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
}}
|
|
133
|
+
#saveButton:hover {{
|
|
134
|
+
background: #45a049;
|
|
135
|
+
}}
|
|
136
|
+
</style>
|
|
137
|
+
|
|
138
|
+
<div id="sidebar">
|
|
139
|
+
<h3 style="text-align:center;">Node Details</h3>
|
|
140
|
+
<div id="nodeInfo">
|
|
141
|
+
<p><b>Click a node</b> to view details.</p>
|
|
142
|
+
</div>
|
|
143
|
+
<hr>
|
|
144
|
+
<div id="menuBar" style="display:none; text-align:center;">
|
|
145
|
+
<button onclick="menuAction('edit')">✏️ Edit</button>
|
|
146
|
+
<button onclick="menuAction('delete')">🗑️ Delete</button>
|
|
147
|
+
<button id="expandBtn" onclick="menuAction('expand')">🔽 Expand</button>
|
|
148
|
+
</div>
|
|
149
|
+
<div id="expandMenu"></div>
|
|
150
|
+
<button id="saveButton" onclick="saveTree()">💾 Save Tree</button>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<script>
|
|
154
|
+
var treeData = {json.dumps(tree_data)};
|
|
155
|
+
|
|
156
|
+
// Recursive red propagation
|
|
157
|
+
function updateRedness() {{
|
|
158
|
+
const redNodes = new Set();
|
|
159
|
+
function isRed(nodeId) {{
|
|
160
|
+
const node = treeData[nodeId];
|
|
161
|
+
if(node.children.length === 0) return !!node.highlight;
|
|
162
|
+
for(let c of node.children) {{
|
|
163
|
+
if(isRed(c)) return true;
|
|
164
|
+
}}
|
|
165
|
+
return false;
|
|
166
|
+
}}
|
|
167
|
+
for(let nodeId in treeData) {{
|
|
168
|
+
if(isRed(nodeId)) redNodes.add(nodeId);
|
|
169
|
+
}}
|
|
170
|
+
network.body.data.nodes.forEach(n => {{
|
|
171
|
+
let baseColor = (treeData[n.id].type === 'root') ? "#ffcc00" :
|
|
172
|
+
(treeData[n.id].type === 'branch') ? "#66ccff" : "#99ff99";
|
|
173
|
+
n.color = redNodes.has(n.id) ? "red" : baseColor;
|
|
174
|
+
}});
|
|
175
|
+
network.redraw();
|
|
176
|
+
}}
|
|
177
|
+
|
|
178
|
+
// Node click → sidebar
|
|
179
|
+
network.on("click", function(params){{
|
|
180
|
+
hideExpandMenu();
|
|
181
|
+
if(params.nodes.length > 0){{
|
|
182
|
+
var nodeId = params.nodes[0];
|
|
183
|
+
var node = treeData[nodeId];
|
|
184
|
+
document.getElementById("nodeInfo").innerHTML =
|
|
185
|
+
"<p><b>Name:</b> " + nodeId + "</p>" +
|
|
186
|
+
"<p><b>Type:</b> " + node.type + "</p>" +
|
|
187
|
+
"<p><b>Value:</b> " + node.value + "</p>" +
|
|
188
|
+
"<p><b>Children:</b> " + (node.children.join(", ") || "None") + "</p>";
|
|
189
|
+
document.getElementById("menuBar").style.display = "block";
|
|
190
|
+
document.getElementById("menuBar").setAttribute("data-node", nodeId);
|
|
191
|
+
}}
|
|
192
|
+
}});
|
|
193
|
+
|
|
194
|
+
// Menu actions
|
|
195
|
+
function menuAction(action){{
|
|
196
|
+
var nodeId = document.getElementById("menuBar").getAttribute("data-node");
|
|
197
|
+
if(action === 'expand') showExpandMenu(treeData[nodeId]);
|
|
198
|
+
else if(action === 'delete') deleteNode(nodeId);
|
|
199
|
+
else alert(action + " action on node: " + nodeId);
|
|
200
|
+
}}
|
|
201
|
+
|
|
202
|
+
// Expand menu
|
|
203
|
+
function showExpandMenu(node){{
|
|
204
|
+
var menu = document.getElementById("expandMenu");
|
|
205
|
+
menu.innerHTML = "";
|
|
206
|
+
if(node.children.length === 0){{
|
|
207
|
+
menu.innerHTML = "<div><i>No children</i></div>";
|
|
208
|
+
}} else {{
|
|
209
|
+
node.children.forEach(c => {{
|
|
210
|
+
var item = document.createElement("div");
|
|
211
|
+
item.textContent = c;
|
|
212
|
+
if(treeData[c] && treeData[c].highlight){{
|
|
213
|
+
item.style.color = "red";
|
|
214
|
+
item.style.fontWeight = "bold";
|
|
215
|
+
}}
|
|
216
|
+
item.onclick = function(){{ alert("Selected child: " + c); hideExpandMenu(); }};
|
|
217
|
+
menu.appendChild(item);
|
|
218
|
+
}});
|
|
219
|
+
}}
|
|
220
|
+
var expandBtn = document.getElementById("expandBtn");
|
|
221
|
+
var rect = expandBtn.getBoundingClientRect();
|
|
222
|
+
menu.style.left = rect.left + "px";
|
|
223
|
+
menu.style.top = (rect.bottom + window.scrollY) + "px";
|
|
224
|
+
menu.style.display = "block";
|
|
225
|
+
}}
|
|
226
|
+
|
|
227
|
+
function hideExpandMenu(){{ document.getElementById("expandMenu").style.display = "none"; }}
|
|
228
|
+
window.addEventListener('click', function(e){{
|
|
229
|
+
var menu = document.getElementById("expandMenu");
|
|
230
|
+
if(!menu.contains(e.target) && e.target.id !== 'expandBtn') hideExpandMenu();
|
|
231
|
+
}});
|
|
232
|
+
|
|
233
|
+
// Delete node
|
|
234
|
+
function deleteNode(nodeId){{
|
|
235
|
+
if(confirm("Delete node '" + nodeId + "'?")){{
|
|
236
|
+
for(let key in treeData){{
|
|
237
|
+
let idx = treeData[key].children.indexOf(nodeId);
|
|
238
|
+
if(idx !== -1) treeData[key].children.splice(idx, 1);
|
|
239
|
+
}}
|
|
240
|
+
delete treeData[nodeId];
|
|
241
|
+
network.body.data.nodes.remove({{id: nodeId}});
|
|
242
|
+
document.getElementById("nodeInfo").innerHTML = "<p><b>Click a node</b> to view details.</p>";
|
|
243
|
+
document.getElementById("menuBar").style.display = "none";
|
|
244
|
+
hideExpandMenu();
|
|
245
|
+
updateRedness();
|
|
246
|
+
}}
|
|
247
|
+
}}
|
|
248
|
+
|
|
249
|
+
// Save tree
|
|
250
|
+
function saveTree(){{
|
|
251
|
+
const jsonData = JSON.stringify(treeData, null, 2);
|
|
252
|
+
const blob = new Blob([jsonData], {{ type: "application/json" }});
|
|
253
|
+
const url = URL.createObjectURL(blob);
|
|
254
|
+
const a = document.createElement("a");
|
|
255
|
+
a.href = url;
|
|
256
|
+
a.download = "tree_data.json";
|
|
257
|
+
document.body.appendChild(a);
|
|
258
|
+
a.click();
|
|
259
|
+
document.body.removeChild(a);
|
|
260
|
+
URL.revokeObjectURL(url);
|
|
261
|
+
}}
|
|
262
|
+
|
|
263
|
+
// Initial red calculation
|
|
264
|
+
updateRedness();
|
|
265
|
+
</script>
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
with open("tree.html", "w") as f:
|
|
269
|
+
f.write(html.replace("</body>", extra_js + "</body>"))
|
|
270
|
+
|
|
271
|
+
print("✅ Open tree.html in your browser")
|
|
272
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
gcc_slycooper50/tree_app.py,sha256=jZEvJl9vGWMUea75_FIs-RW1muaE577NNc7w_zoAhHM,8392
|
|
2
|
+
gcc_slycooper50-0.1.130.dist-info/licenses/LICENSE,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
3
|
+
gcc_slycooper50-0.1.130.dist-info/METADATA,sha256=kaxcjcNnGwWjE2DAN0n8afx7pVikvn5t8oX04kT0HsA,356
|
|
4
|
+
gcc_slycooper50-0.1.130.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
gcc_slycooper50-0.1.130.dist-info/top_level.txt,sha256=yDxkl8ek8lYZRCxgy1mWsk0qEPq8BBIkw_EQIlq5_q8,16
|
|
6
|
+
gcc_slycooper50-0.1.130.dist-info/RECORD,,
|
|
Binary file
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
gcc_slycooper50/glad-2.0.8.tar.gz,sha256=RPBvkZVCfHAX9QKNCJT1frIWsKj3xO2nzog3Mq6y0Pw,645593
|
|
2
|
-
gcc_slycooper50-0.1.128.dist-info/licenses/LICENSE,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
3
|
-
gcc_slycooper50-0.1.128.dist-info/METADATA,sha256=_UAUmdvl6PzHgWfoVAT7_pU3t-HOnrNJBTfi4NPvlIc,356
|
|
4
|
-
gcc_slycooper50-0.1.128.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
-
gcc_slycooper50-0.1.128.dist-info/top_level.txt,sha256=yDxkl8ek8lYZRCxgy1mWsk0qEPq8BBIkw_EQIlq5_q8,16
|
|
6
|
-
gcc_slycooper50-0.1.128.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|