Closed williamstein closed 2 months ago
Probably this involves:
I'd add that this would provide a very convenient way to incorporate turtle graphics in a notebook for teaching, along with efficient graphics for games and visualizations like 'game of life'.
This is a custom widget, and our goal with jupyter now is that ALL custom widgets be fully supported. I just tried this and something mysterious does go wrong:
This also does not work for my in JupyterLab 3.6:
Ipycanvas is also broken for me in a fresh install with JupyterLab 4.2.3:
It does work in colab, though you have to do something special to enable it (for security reasons):
but I think colabs widgets setup is several years old (?), so it's maybe more likely to support something that used to work:
In any case, it's very likely a bug that this doesn't work, and we should support it.
Upstream issues saying this is broken on mybinder:
!pip install ipycanvas
from ipycanvas import Canvas
canvas = Canvas(width=200, height=200)
canvas.fill_rect(25, 25, 100, 100)
canvas.clear_rect(45, 45, 60, 60)
canvas.stroke_rect(50, 50, 50, 50)
canvas
This DOES work in JupyterLab 4.2.4. Definitely a bug to be fixed:
The basics work, but something else goes wrong with this example from the docs:
from ipycanvas import Canvas
canvas = Canvas(width=100, height=50)
def perform_drawings():
canvas.font = "32px serif"
canvas.fill_text("Voilà!", 10, 32)
canvas
then in another cell
perform_drawings()
It works the first time. If you then refresh the browser, it crashes and further evaluation does not work.
This is also broken in the same way when used with JupyterLab.
This is an upstream bug that has been opened 1.5 years with no comment: https://github.com/jupyter-widgets-contrib/ipycanvas/issues/322
So basically now cocalc matches the jupyterlab behavior, which is the best we can hope for.
I'm going to close this; it's not our bug and I don't know what to do about it.
See https://ipycanvas.readthedocs.io/en/latest/