-
Notifications
You must be signed in to change notification settings - Fork 963
Closed
Labels
discussiongood first issueresolved-lockedClosed issues are locked after 30 days inactivity. Please open a new issue for related discussion.Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone
Description
Summary:
Add the examples in #1287 (comment) and #1287 (comment) to the docs as an advanced example for having a request/reply pattern with widgets using generator-like syntax
Original issue
I can check for updates to a widget value using observe:
import ipywidgets as widgets
from IPython.display import display
import time
w = widgets.Dropdown(
options=['Addition', 'Multiplication', 'Subtraction'],
value='Addition',
description='Task:',
)
def on_change(change):
print("changed to %s" % change['new'])
w.observe(on_change)
display(w)But how can I do that during another operation, for example:
for i in range(100):
time.sleep(1)
# pull for changes to w here.
# if w.has_changed:
# print(w.value)I tried doing something like
import IPython
ipython = IPython.get_ipython()
ipython.kernel.do_one_iteration()to pull for updates. But is seems unreliable. Is there a better way to do this?
Metadata
Metadata
Assignees
Labels
discussiongood first issueresolved-lockedClosed issues are locked after 30 days inactivity. Please open a new issue for related discussion.Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.