Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for responding to node/edge click events #85

Open
khughitt opened this issue Mar 4, 2021 · 3 comments
Open

Add support for responding to node/edge click events #85

khughitt opened this issue Mar 4, 2021 · 3 comments

Comments

@khughitt
Copy link

khughitt commented Mar 4, 2021

Greetings!

I'm not sure if this is within the scope of what you have in mind (or what is possible) with pyvis, but is there any chance support could be added to respond to node/edge click handlers (and perhaps, later, other events like "unfocus")?

This way, one could imagine doing something like embedding a pyvis network view inside a PyQt application, with a network view on one side, for which, selecting a node will trigger an event / change the view in the other part of the application.

Just a thought..

Feel free to close / triage this though if this is too far outside the scope of what you have in mind.

Either way, thanks for taking the time to create this and share it with the community! It is much appreciated.

@boludo00
Copy link
Collaborator

Hi! This is absolutely something I always wanted to support. I am in the process of actually making this possible which involved restructuring the way some of dependencies were handled so these custom interactions could live in one JS file bundled with pyvis. I have a little something going on with #91 but as it stands, the current idea is to just have these custom interactions be coded in the JS file that gets served with the template. If the community is intrigued enough by this I hope contributions can be made by some JS ninjas to support a whole range of interactions :)

@mrceresa
Copy link

Thanks Giancarlo and Keith for the nice discussion. This is something I would also be very interested!

In the previous PR you will find the code in "experimental" able to merge.

I saw that this code uses the network.on method to register an handler and the corresponding callback. I was making some tests with pyqt and it is actually possible to run code with webEngineView.page().runJavaScript('console.log("test")').

The JS code can then return values though a callback (Plain data and all of the JSON data types as well as, for example, Date and ArrayBuffer)

There seems to be the concrete possibility to have a bidirectional communication between pyqt and pyvis :)

Let me know if you are interested in discussing this further

@kotop
Copy link

kotop commented Jun 20, 2022

Hi.
Can you explain your answer or give a link to them?
"In the previous PR you will find the code in "experimental" able to merge.

I saw that this code uses the network.on method to register an handler and the corresponding callback. I was making some tests with pyqt and it is actually possible to run code with webEngineView.page().runJavaScript('console.log("test")').

The JS code can then return values though a callback (Plain data and all of the JSON data types as well as, for example, Date and ArrayBuffer)"

Is it possible to see this example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants