Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support the ipycanvas widget in cocalc-jupyter #5159

Closed
williamstein opened this issue Jan 10, 2021 · 7 comments
Closed

support the ipycanvas widget in cocalc-jupyter #5159

williamstein opened this issue Jan 10, 2021 · 7 comments

Comments

@williamstein
Copy link
Contributor

See https://ipycanvas.readthedocs.io/en/latest/

@williamstein
Copy link
Contributor Author

Probably this involves:

  1. Installing all the relevant code for the upstream project, and
  2. Porting the frontend code to cocalc-jupyter, since it probably (?) uses the generic widget extensions feature, which we don't support.

@sheinb
Copy link

sheinb commented Jan 13, 2021

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'.

@williamstein
Copy link
Contributor Author

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:

image

This also does not work for my in JupyterLab 3.6:

image

Ipycanvas is also broken for me in a fresh install with JupyterLab 4.2.3:

image

It does work in colab, though you have to do something special to enable it (for security reasons):

image

but I think colabs widgets setup is several years old (?), so it's maybe more likely to support something that used to work:
image

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:

@williamstein
Copy link
Contributor Author

!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

@williamstein
Copy link
Contributor Author

This DOES work in JupyterLab 4.2.4. Definitely a bug to be fixed:

image

@williamstein
Copy link
Contributor Author

williamstein commented Aug 1, 2024

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: jupyter-widgets-contrib/ipycanvas#322

So basically now cocalc matches the jupyterlab behavior, which is the best we can hope for.

@williamstein williamstein reopened this Aug 1, 2024
@williamstein
Copy link
Contributor Author

I'm going to close this; it's not our bug and I don't know what to do about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants