-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Block kernel until ipywidget's initial rendering has completed #3144
Comments
I would expose a |
Relevant other points of note, that might or might not be useful:
|
Hi @vidartf I am also looking for a method to block execution until specific event happens, but it turns out that the event won't be sent if the main thread of Jupyter is blocking. For example, import asyncio
from IPython.display import display
from ipywidgets import Text
def wait_for_change(widget, value):
future = asyncio.Future()
def getvalue(change):
# make the new value available
future.set_result(change.new)
widget.unobserve(getvalue, value)
widget.observe(getvalue, value)
return future
text_input = Text()
print('before', text_input.value)
display(text_input)
future = wait_for_change(text_input, 'value')
await asyncio.ensure_future(future) # block forever, the future didn't get resolved after user finishing input
# never reach this line
print(text_input.value) There are more examples in the SO issue: https://stackoverflow.com/questions/77363909/how-to-block-execution-until-jupyter-widgets-value-has-been-changed Is there any solution to make it work? |
Question:
I am building a custom ipywidget and the first rendering of widget (in output cell) takes some time. The following cells in the notebook interact with the widget and it requires the widget to be fully rendered before interacting with it in other cells.
There is no python function which I can await, as the widget start rendering as soon as we execute the widget class's object
In other words, I want the kernel to wait until
DOMWidgetView.render()
has finished rendering in output cell.The text was updated successfully, but these errors were encountered: