jupyter-widgets / tutorial

A tutorial for widgets
BSD 3-Clause "New" or "Revised" License
394 stars 164 forks source link

Fix errors in `07.01-ipycanvas` -- no attribute 'size' #178

Closed mwcraig closed 2 years ago

mwcraig commented 2 years ago

The custom scatter plot and the game of life example fail because the canvas has no attribute size.

E.g. for the game of life example:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [8], in <cell line: 50>()
     48 canvas.fill_style = '#FFF0C9'
     49 canvas.stroke_style = 'white'
---> 50 canvas.fill_rect(0, 0, canvas.size[0], canvas.size[1])
     52 draw(x, canvas, '#5770B3')
     54 display(canvas)

AttributeError: 'RoughCanvas' object has no attribute 'size'
martinRenou commented 2 years ago

Mmmh this is due to the removal of this property in latest ipycanvas versions. The proper change should be canvas.fill_rect(0, 0, canvas.width, canvas.height). I can send a PR.

mwcraig commented 2 years ago

Thanks!