Skip to content

Commit 978af97

Browse files
committed
Make client ready event optional
This is for xcanvas to not fail at construction. There seem to be an issue in xwidgets for when we send a custom comm message too early.
1 parent 89941be commit 978af97

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ipycanvas/canvas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ class Canvas(_CanvasBase):
254254
_model_name = Unicode('CanvasModel').tag(sync=True)
255255
_view_name = Unicode('CanvasView').tag(sync=True)
256256

257+
_send_client_ready_event = Bool(True).tag(sync=True)
258+
257259
#: (valid HTML color or Gradient or Pattern) The color for filling rectangles and paths. Default to ``'black'``.
258260
fill_style = Union((Color(), Instance(_CanvasGradient), Instance(Pattern)), default_value='black')
259261

src/widget.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class CanvasModel extends DOMWidgetModel {
244244
height: 500,
245245
sync_image_data: false,
246246
image_data: null,
247+
_send_client_ready_event: true,
247248
};
248249
}
249250

@@ -275,7 +276,9 @@ class CanvasModel extends DOMWidgetModel {
275276
this.on('change:sync_image_data', this.syncImageData.bind(this));
276277
this.on('msg:custom', this.onCommand.bind(this));
277278

278-
this.send({ event: 'client_ready' }, {});
279+
if (this.get('_send_client_ready_event')) {
280+
this.send({ event: 'client_ready' }, {});
281+
}
279282
}
280283

281284
private async drawImageData() {

0 commit comments

Comments
 (0)