Brython is a very cool project. With it you can write python scripts directly inside an html document. However, I can't figure out how the turtle graphics library works with Brython. They have a demo page with turtle graphics: https://www.brython.info/gallery/turtle.html but I want something simpler, without the demo selector and without showing the python code in the html page.
Has anyone written a simple turtle demo with Brython? If so, what is the html document for it from start to finish?
Brython is a very cool project. With it you can write python scripts directly inside an html document. However, I can't figure out how the turtle graphics library works with Brython. They have a demo page with turtle graphics: https://www.brython.info/gallery/turtle.html but I want something simpler, without the demo selector and without showing the python code in the html page.
Has anyone written a simple turtle demo with Brython? If so, what is the html document for it from start to finish?
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/035dc845-f7bf-4c89-b896-94742fdc92f9n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/bf4a88f4-f59a-40d3-920d-2ab52d0e5023n%40googlegroups.com.
Martyn, thank you so much for your help!First time run takes about 14 seconds on my PC. Second run is almost instant. This doesn't change when I load the libraries localy.Does it run instantly on your PC from the first run (i.e. when you make a change in html code and rerun it) ?
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/4db514ef-381e-4bd9-9433-900fd2fcc317n%40googlegroups.com.
Hello,I have also noticed that loading the module takes a few seconds the first time (much less on next runs if brython_stdlib.js is used, thanks to the cache). This is because it imports 2 modules from the standard distribution, copy and inspect, which themselves import a few dozens of modules. Without the cache, loading and translating all these Python scripts is not immediate.In this gist I have slightly modified the code of turtle.py to avoid importing these modules. For copy, all it takes is to use the dict method copy() instead of copy.copy(dictionary).
For inspect I had to make a little more changes, ignoring the signature of methods and replacing it by (*args, **kw) - maybe there are side effects that I don't think of.
With these changes, even without brython_stdlib.js the example runs almost without any delay.André, que penses-tu de cette version ?
Pierre--Le mercredi 18 novembre 2020 à 15:04:59 UTC+1, André a écrit :On Wednesday, 18 November 2020 at 08:16:16 UTC-4 pant...@gmail.com wrote:Martyn, thank you so much for your help!First time run takes about 14 seconds on my PC. Second run is almost instant. This doesn't change when I load the libraries localy.Does it run instantly on your PC from the first run (i.e. when you make a change in html code and rerun it) ?It normally should not take that long. However, as *I* wrote for the demo (yes, I am the guilty party who wrote the "new" turtle module quite a while ago):" The first time you do this, Brython has to do extra work to translate the turtle module from Python into Javascript; subsequent runs will be faster."Note that the translation stage takes about one second for the simplest demo on the Brython site. I have no idea why it would take so long on your own computer. Can you try with different browsers? I see significant time differences between Chrome and Firefox when I run the "Complex scene" example from Brython's site.André Roberge--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/brython/bf4a88f4-f59a-40d3-920d-2ab52d0e5023n%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "brython" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/brython/zBaCGkSIXp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to brython+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/ea331262-8fc6-4f9b-9236-877331ce94b0n%40googlegroups.com.
I am trying to assign a GIF image to a turtle in Brython but I think that the register_shape method is not implemented.Is there anything I can do?
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/c9869907-0bdd-4e53-87cc-c2e0d25de91an%40googlegroups.com.