Open edublancas opened 10 months ago
Hi @edublancas!
It does seem like there are some issues with ipycanvas in solara. I'm using ipycanvas 0.12.1, since higher versions don't seem compatible at all.
There's a hidden example on using ipycanvas here... Although I checked and it doesn't seem to be working as is, so I'll be taking a look at fixing things.
Interestingly, this code
import solara
import ipycanvas
from reacton import ipycanvas as c
from reacton import ipywidgets as w
count = solara.reactive(0)
@solara.component
def Page():
solara.Button(f"Draw {count.value}", on_click=lambda: count.set(count.value + 1))
def draw():
print(canvas_element)
canvas = solara.get_widget(canvas_element)
print(canvas)
with ipycanvas.hold_canvas(canvas):
canvas.fill_style = "#63934e"
canvas.fill_rect(10 * count.value, 10 * count.value, 10, 10)
solara.use_effect(draw, [count.value])
canvas_element = c.Canvas(
width=700,
height=500,
)
print(canvas_element)
Page = Page()
Page
runs fine if you execute it through a notebook cell (solara run app.ipynb
), but not if you run it as a standalone app.
awesome, thanks for looking at this!
in case it helps, there are some notes in the docs about why ipycanvas doesn't work out of the box in Voila (perhaps they're related to why they don't work on Solara?): https://ipycanvas.readthedocs.io/en/latest/advanced.html#ipycanvas-in-voila
I want to develop an app that uses solara and ipycanvas, but it seems like ipycanvas isn't supported.
App code:
Then, I start the app:
And I get this error:
Is this expected? Are there any workarounds?