Closed
Description
When trying to draw anything using ipycanvas
in JupyterLab, I'm getting a blank canvas displayed and no image data being stored even with sync_image_data = True
. I'm not using Voila here, though the blank canvas display looks similar to #342 and I've tried the solution there.
import numpy as np
from ipycanvas import Canvas
canvas = Canvas(width=200, height=200, sync_image_data = True)
canvas.fill_rect(25, 25, 100, 100)
canvas.clear_rect(45, 45, 60, 60)
canvas.stroke_rect(50, 50, 50, 50)
canvas.get_image_data()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[8], line 10
7 canvas.clear_rect(45, 45, 60, 60)
8 canvas.stroke_rect(50, 50, 50, 50)
---> 10 canvas.get_image_data()
File [/opt/conda/lib/python3.11/site-packages/ipycanvas/canvas.py:444](https://teachinghub.st-andrews.ac.uk/opt/conda/lib/python3.11/site-packages/ipycanvas/canvas.py#line=443), in _CanvasBase.get_image_data(self, x, y, width, height)
435 """Return a NumPy array representing the underlying pixel data for a specified portion of the canvas.
436
437 This will throw an error if there is no ``image_data`` to retrieve, this happens when nothing was drawn yet or
(...)
441 are (``x + width``, ``y + height``).
442 """
443 if self.image_data is None:
--> 444 raise RuntimeError(
445 "No image data, please be sure that ``sync_image_data`` is set to True"
446 )
448 x = int(x)
449 y = int(y)
RuntimeError: No image data, please be sure that ``sync_image_data`` is set to True
Versions are as follows:
Jupyterlab 4.2.0
ipycanvas 0.13.3
ipywidgets 8.1.2
Any help appreciated, and I'm happy to help get more details.
Metadata
Assignees
Labels
No labels