knowledge-repo
knowledge-repo copied to clipboard
ipywidgets not rendering in posts
Auto-reviewers: @NiharikaRay @matthewwardrop @earthmancash @danfrankj
Hi! I'm trying to render an interactive textbox via ipywidgets with the following code.
import ipywidgets as widgets
from IPython.display import display
text = widgets.Text(
value='',
placeholder='',
description='Query:',
disabled=False
)
# print(text)
display(text)
text.on_submit(handle_submit)
The textbox appears in my notebook but does not appear in the knowledge repo. When I print the text object I get
<ipywidgets.widgets.widget_string.Text object at 0x7eff10343438>
even though nothing is rendered. Wondering if ipywidgets objects are supported? Does it have something to do with having to enable an extension (jupyter nbextension enable --py --sys-prefix widgetsnbextension) for the rendering to work?
Any help here would be greatly appreciated! Thanks!
Hi @dhango
We recently made some changes regarding support for javascript in knowledge posts, which may have fixed this issue too. Can you check whether the master branch still has this issue? If so, we'll look into it at some point :).
Thanks for reporting it!
Thanks for getting back @matthewwardrop !
I checked the master branch and ipywidgets still do not render. I tried creating the text box in pure JS and that rendered fine, so this may be something specific to ipywidgets. I really appreciate the help!
@dhango ipywidgets rely on the python kernel backend being present so they won't with the knowledge_repo the way you are hoping (I think). The best you would get is the JS controls that don't do anything similar to what you see here: https://nbviewer.jupyter.org/github/jupyter-widgets/ipywidgets/blob/2940f9f56f63257902b27509f18e872e77c3c014/docs/source/examples/Widget%20Basics.ipynb
Hey,
I was wondering if this issue has been worked on this it was submitted? Do the ipywidgets render now?
Thanks
I'm also wondering whether it's possible for KR to support ipywidgets.
@robertdefilippi @jpzhangvincent I believe for ipywidgets to work in the knowledge repo, the widgets would need to be translated to pure JS as @dhango suggested.
Internally at Airbnb, we have already done this for .Rmd notebooks with an R package, but I don't think we have a solution for Python yet. If you submit a PR for this happy to review and merge.
@bulam I'm wondering whether Plotly charts in jupyter notebook with R kernel would be properly rendered.
@jpzhangvincent that's an interesting question. Haven't tried this!