【发布时间】:2019-06-01 03:34:10
【问题描述】:
我正在尝试从运行 Python 3.6 中的 Jupyter Notebooks 的 Microsoft Azure Notebooks 中的 ipywidgets 小部件获取输出。但是,当我得到它们时它不会返回新值。这也适用于从不为其他小部件调用的事件处理程序/交互。
我尝试使用不同类型的小部件(Text、Textarea、Checkbox、Button、ToggleButton)输入不同的初始值。我尝试在按钮上设置w.value、ipywidgets.interact、w.observe 和w.on_click。
我做的一个测试:
import time
import ipywidgets as widgets
from IPython.display import display
w = widgets.Text(disabled=False)
display(w)
while True:
print(w.value)
time.sleep(1)
我希望当我在 Text 字段中输入内容时,它会输出该文本,但它会继续打印出它开始的内容。没有错误。因此,对于上面的示例,无论我在结果文本字段中输入什么,打印的都是空行。
【问题讨论】:
标签: python jupyter-notebook ipywidgets azure-notebooks