Added event handling support to VisNetwork and enhanced component documentation

This commit is contained in:
2025-12-02 20:46:54 +01:00
parent e34d675e38
commit 378775cdf9
12 changed files with 123 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
from myfasthtml.controls.Panel import Panel
from myfasthtml.controls.VisNetwork import VisNetwork
from myfasthtml.core.commands import LambdaCommand
from myfasthtml.core.instances import SingleInstance, InstancesManager
from myfasthtml.core.network_utils import from_parent_child_list
@@ -11,7 +12,8 @@ class InstancesDebugger(SingleInstance):
def render(self):
nodes, edges = self._get_nodes_and_edges()
vis_network = VisNetwork(self, nodes=nodes, edges=edges, _id="-vis")
c = LambdaCommand(lambda event_data: print("received", event_data))
vis_network = VisNetwork(self, nodes=nodes, edges=edges, _id="-vis", events_handlers={"select_node": c})
return self._panel.set_main(vis_network)
def _get_nodes_and_edges(self):