-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support for pyvis #63
Comments
+1 for requesting support of pyvis |
It's important to note that, in that example, pyvis' That being said, there's nothing preventing you from doing basically the same thing as that example with vanilla shiny (no shinywidgets necessary). import os
from shiny import *
import networkx as nx
from pyvis.network import Network
# set up a static_assets folder for holding the Network()'s html file
DIR = os.path.dirname(os.path.abspath(__file__))
WWW = os.path.join(DIR, "www")
PYVIS_OUTPUT_ID = "pyvis"
ui_app = ui.page_fluid(
ui.output_ui(PYVIS_OUTPUT_ID),
)
def server(input: Inputs, output: Outputs, session: Session):
@output(id=PYVIS_OUTPUT_ID)
@render.ui
def _():
G = nx.Graph()
G.add_nodes_from([1, 2, 3])
G.add_edges_from([[1, 2], [2, 3], [3, 1]])
net = Network()
net.from_nx(G)
net.toggle_drag_nodes(False)
net.generate_html(local=False)
f = os.path.join(WWW, PYVIS_OUTPUT_ID + ".html")
with open(f, "w") as f:
f.write(net.html)
return ui.tags.iframe(
src=PYVIS_OUTPUT_ID + ".html",
style="height:600px;width:100%;",
scrolling="no",
seamless="seamless",
frameBorder="0",
)
app = App(ui=ui_app, server=server, static_assets=WWW) |
By the way, until pyvis gains support for the ipywidgets protocol, there's nothing really for shinywidgets to do, so I'll be adding a "wontfix" tag to reinforce that point. It's also worth noting pyvis isn't the only "widget" library that's in this situation (see for example, #54) |
Hi @cpsievert thank you for explaining. The iframe suggestion looks like a good solution. @obkhan maybe you should create an issue in the pyvis repo to propose the idea of pyvis support for jupyter widgets. |
Description
Requesting support to be able to use the pyvis library with Shiny for Python https://pyvis.readthedocs.io/en/latest/index.html.
Here is an example where someone was able to register pyvis with ipywidgets WestHealth/pyvis#93.
The text was updated successfully, but these errors were encountered: