berinhard / pyp5js

Python to P5.js Transcriptor
https://berinhard.github.io/pyp5js/
GNU Lesser General Public License v3.0
201 stars 37 forks source link

future feature discussion: multiple sketches in a single pyodide page #134

Open villares opened 3 years ago

villares commented 3 years ago

As I was looking at how it would feel to have a sketch running on pyodide without the editor (here) I wonder if we could make many sketch instances work in single pyodide.

berinhard commented 3 years ago

@villares yes, we can. I think it's just a matter of:

  1. Enabling the user to pass what is the HTML element id to place the skecth. Currently it uses only sketch-holder
  2. Stop using window.instance to store the p5.js sketch object and change it to a Javascript object. Something like:
sketch_holder = "sketch_holder"  // this can be passed by users via argument or something like that
window.pyp5js_instances = {sketch_holder:  window.instance = p5.new(sketch_setup, sketch_holder)}

The only thing to have in mind is that this should also work for Transcrypt. And this is the thing that most frighten me about having n + 1 interpreters: making sure all features are available to all of them.

IMHO, although this feature is something interesting in terms of web, I don't know if it's going be enabled in pyp5js next. I feel that there are issues with more impacts that will come first such as #132, #125 and #124.

berinhard commented 3 years ago

Probably once we have #189 done, this issue should also have been fixed.