I don’t understand why the canvas on my app only works on the first page of a data grid. I think it is a bug, but I might be missing something.
This test app has these components: data grid - repeating panel - row template - canvas:
https://anvil.works/build#clone:WVVMXLRMPKPV6UJ3=VB4MQRPJE3JJNH3V7WZMBUEA
The canvas is updated on 4 places: the __init__
and the form_show
of the row template form, the canvas_1_show
and the canvas_1_reset
events.
It looks like the __init__
has no effect because the canvas is not yet ready, but the form_show
, canvas_1_show
and canvas_1_reset
are doing their job.
Everything works well when the data grid shows the first page, but when navigating to any other page, including going back to the first page, the update_canvas
function is called, but the canvas doesn’t show any graphics.
Adding self.canvas_1.reset_context()
(and removing the canvas_1_reset
event) before each redraw doesn’t help.
Below a snapshot of the real app.
I was able to get it to work by setting a timer’s interval to 0.01 on each form_show
, then calling the function that updates the canvas on the tick
event. It works, but there is some nasty flickering (because the whole page is shown first without graphics, then with graphics) and other side effects that I really would like to avoid: