我一直在Jupyter笔记本中使用iPython小部件,但是依赖于启用应用程序模式的扩展程序无效,所以我决定尝试将它全部重写为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)