Created
December 14, 2018 08:57
-
-
Save sparkydogX/41b92905e67b8f0214515df92e94c86f to your computer and use it in GitHub Desktop.
在jupyter notebook中使用button更新图像.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython import display | |
import time | |
import ipywidgets | |
from ipywidgets import widgets | |
button = widgets.Button(description = "Click") | |
out = widgets.Output() | |
display.display(widgets.VBox([out,button],layout=ipywidgets.Layout(align_items='center'))) | |
def on_button_clicked(b): | |
plt.plot(pylab.randn(100)) | |
with out: | |
display.clear_output(wait=True) | |
plt.show() | |
button.on_click(on_button_clicked) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
将使用button控制改成sleep一段时间更新图像可以作为播放video的方式, sleep的时间取决于帧率.