-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates diagram viewer dependencies; enables select and move callback…
…s in NadWidget Signed-off-by: Christian Biasuzzi <[email protected]>
- Loading branch information
Showing
5 changed files
with
224 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "747ca44b-4aea-461b-8046-e7ce940297f8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pypowsybl_jupyter import display_nad\n", | ||
"import ipywidgets as widgets\n", | ||
"import pypowsybl as pp" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "438c80d3-bf89-4eca-af8e-b9799d903d8c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"network = pp.network.create_four_substations_node_breaker_network()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "aa321947-692e-4016-bf76-590628637a3e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#declare some example callbacks, to simply log the events in a output box\n", | ||
"out1 = widgets.Output()\n", | ||
"def print_infos(data): \n", | ||
" with out1:\n", | ||
" print(data)\n", | ||
"print_infos('Events log:')\n", | ||
"\n", | ||
"def test_select_node_callback(event):\n", | ||
" print_infos('Selected node: ' + str(event.selected_node))\n", | ||
"\n", | ||
"def test_move_node_callback(event):\n", | ||
" print_infos('Moved node: ' + str(event.moved_node))\n", | ||
"\n", | ||
"def test_move_text_node_callback(event):\n", | ||
" print_infos('Moved text node: ' + str(event.moved_text_node))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "63745ac5-e1f2-4182-a03b-5bdbe41c3b3e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#create a NAD widget for a network and activate the callbacks\n", | ||
"nad_widget=display_nad(network.get_network_area_diagram(depth=4), enable_callbacks=True)\n", | ||
"nad_widget.on_select_node(test_select_node_callback)\n", | ||
"nad_widget.on_move_node(test_move_node_callback)\n", | ||
"nad_widget.on_move_text_node(test_move_text_node_callback)\n", | ||
"\n", | ||
"#finally, display the widgets\n", | ||
"widgets.HBox([nad_widget, out1])" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters