我一直在Jupyter笔记本中使用iPython小部件,但是我用来启用App Mode的扩展名无法正常工作,因此我决定尝试将其全部重写为Python / Flask,但我没有想知道如何或是否有可能在Flask视图中使用iPython小部件(特别是交互式)?
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)