Issue
I've been using iPython widgets in a Jupyter notebook, but the extension I was depending on to enable App Mode is not working, so I've decided to try to rewrite it all to Python/Flask, but I have no idea how, or if it's at all possible, to use iPython widgets in Flask views (especially interactive)?
import ipywidgets as widgets
items_layout = widgets.Layout(flex='1 1 auto',
width='400px', height='200px')
box_layout = widgets.Layout(display='flex',
flex_flow='row',
align_items='stretch',
width='100%')
instruction = widgets.Textarea(description="Command",
value = "",
layout = items_layout)
code = widgets.Textarea(description="Code",
value = "",
layout = items_layout)
interactive_plot = widgets.interactive(run_code, trigger = instruction)
items = [interactive_plot, code]
box = widgets.Box(children=items, layout=box_layout)
display(box)
Solution
Below is response from ipywidgets repository issue about similar subject.
In order for the widgets to do something, they must be hooked up to a kernel to do the computation. This requires some extra javascript code and a server somewhere that is providing the python kernel. The web3 example shows one way to do this.
Example of using ipywidgets in web service.
However you will not be able to write widgets code in Python. The whole display of widgets is done with JavaScript code.
Answered By - Konrad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.