How do you connect the python turtle library to an HTML element so it can be seen in the app?

What I’m trying to do: Connect python turtle library to HTML element

What I’ve tried and what’s not working: creating a div with a canvas inside in HTML,

Code Sample:

#imports
from anvil.js import window

class Form2(Form2Template):
def init(self, **properties):
super().init(**properties)
def form_show(self, **event_args):
import turtle
window.Sk.canvas = “turtle”

see this post which is probably the most relevant

I’ve done exactly that: created a customComponnent, but its still not working, and I can’t figure out why. I’m using turtle because it’s what I’m used to and it’s the best for the project I’m doing, but like I said I can’t get it to show in the app.

In that case, it’s probably best to share a clone link so others can see and run your code themselves.

Some instructions here:

Have you tried adding print debug statements? To make sure your form_show event handler is running.
Are you seeing any errors?

Sorry to waste your time but I actually got it working I hadn’t added the handler to tell the form that the form had been showed the trigger form_show but thanks for the feedback anyway.

1 Like