Skip to content

Commit 1ff2193

Browse files
committed
Add support for drawing a MultiCanvas on another Canvas
Signed-off-by: martinRenou <[email protected]>
1 parent cb09602 commit 1ff2193

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ipycanvas/canvas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ def set_line_dash(self, segments):
413413
# Image methods
414414
def draw_image(self, image, x=0, y=0, width=None, height=None):
415415
"""Draw an ``image`` on the Canvas at the coordinates (``x``, ``y``) and scale it to (``width``, ``height``)."""
416-
if (not isinstance(image, (Canvas, Image))):
417-
raise TypeError('The image argument should be an Image widget or a Canvas widget')
416+
if (not isinstance(image, (Canvas, MultiCanvas, Image))):
417+
raise TypeError('The image argument should be an Image, a Canvas or a MultiCanvas widget')
418418

419419
if width is not None and height is None:
420420
height = width

src/widget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class CanvasModel extends DOMWidgetModel {
219219

220220
const image = await unpack_models(serializedImage, this.widget_manager);
221221

222-
if (image instanceof CanvasModel) {
222+
if (image instanceof CanvasModel || image instanceof MultiCanvasModel) {
223223
this._drawImage(image.canvas, x, y, width, height);
224224
return;
225225
}

0 commit comments

Comments
 (0)