cytoscape / ipycytoscape

A Cytoscape Jupyter widget
https://ipycytoscape.readthedocs.io/en/master/
BSD 3-Clause "New" or "Revised" License
264 stars 62 forks source link

Convert javascript events to Node or Edge #268

Open marimeireles opened 3 years ago

marimeireles commented 3 years ago

I was creating some examples to scypy and noticed the events received in this case:

def paint_blue(event):
    auxNode = cyGraph.graph.nodes[int(event['data']['id'])]
    auxNode.classes += ' blue'

cyGraph.on('node', 'click', paint_blue)

Are a perfect Node instance. I think it'd make sense to convert this event to ipycytoscape.Node() on our backend. That'd remove the need to have this line auxNode = cyGraph.graph.nodes[int(event['data']['id'])]. This also works for Edge.