此代码在jupyter notebook中工作,但在jupyterlab中不起作用:
import ipywidgets as widgets
from IPython.display import display
button = widgets.Button(description="Click Me!")
display(button)
def on_button_clicked(b):
print("Button clicked.")
button.on_click(on_button_clicked)
有没有人有解决方案?
ENV:
答案 0 :(得分:3)
当前,仍然知道问题......但here我找到了解决方案。
import ipywidgets as widgets
button = widgets.Button(description='Display Chart')
out = widgets.Output()
def on_button_clicked(b):
button.description = 'clicked'
with out:
print('Ay')
button.on_click(on_button_clicked)
widgets.VBox([button, out])