-
Is there a way the canvas can wait until the hold_canvas has finished updating? Actually, this may not be a hold_canvas issue, but I am using For example, see this gif how the kernel continues to process data, and the canvas image changes: How could I know when the updating is done? (Relatedly, I only need to update the canvas image_data when the hold is done, if it is doing that more than once. Is there a way to see what messages are being processed? Like watching a log in real time?) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
You can listen for def on_update(change):
# This code will actually be called when the canvas `image_data` is updated
canvas.observe(on_update, 'image_data') But if you set this up before starting your animation then What I can suggest in your case is to do the following: # Disable syncing of image_data before the animation
canvas.sync_image_data = False
# Perform your animation here
with hold_canvas(canvas):
# ...
def on_update(change):
# This code will actually be called when the canvas is updated
#
canvas.observe(on_update, 'image_data')
# Ask for syncing the `image_data`, this will trigger the call of `on_update` automatically when the `image_data` is received
canvas.sync_image_data = True I hope I was clear enough. This part is one of the most difficult in ipycanvas, because it's completely async. |
Beta Was this translation helpful? Give feedback.
-
Well, I throttled my draw() method, and now it runs super fast, without overwhelming the kernel. In fact in runs so fast, I had to introduce a wait to slow it down some :) BTW, the throttle code given in the ipywidgets didn't work (I think due to issues running in Jupyter.) But code based on: https://gist.github.com/ChrisTM/5834503 did work. I think this solves all of my issues with ipycanvas! |
Beta Was this translation helpful? Give feedback.
Well, I throttled my draw() method, and now it runs super fast, without overwhelming the kernel. In fact in runs so fast, I had to introduce a wait to slow it down some :) BTW, the throttle code given in the ipywidgets didn't work (I think due to issues running in Jupyter.) But code based on: https://gist.github.com/ChrisTM/5834503 did work. I think this solves all of my issues with ipycanvas!