QuirkyCort / ev3dev-sim

Browser based simulator for ev3dev-lang-python
GNU General Public License v3.0
14 stars 7 forks source link

Blockly style editor to toggle between blocks and code view #3

Closed psychemedia closed 4 years ago

psychemedia commented 4 years ago

I'm not sure how mature it is yet, but https://github.com/blockpy-edu/BlockMirror, from the developers of BlockPy, offers "[a]n interface for dual block/text representation with Blockly".

This allows users to toggle between a code view and a blockly style blocks view, and edit either.

It's based on CodeMirror and also makes use of the Skulpt parser.

I was wondering how easy it would be to switch out your editor with the BlockMirror editor to allow novices users to code your simulator using the blockly editor to begin with and then slowly toggle themselves to using the code editor?

QuirkyCort commented 4 years ago

It's a cool idea and it is one of my long term goal to have a block-based interface. Never looked into it in detail, so thanks for letting me know about BlockMirror.

Having spent a few minutes with BlockMirror (...this one right? https://think.cs.vt.edu/blockpy/blockpy/load), I'm not a 100% on it. The for loop is a direct translation from Python, there are no support for functions, and it runs unconnected blocks in order of the vertical position of the blocks (...I've not seen any block-based programming interface do this last one). The requirement for a modified version of Skulpt is also a concern for me.

I find the Blockly interface from OpenRoberta (https://lab.open-roberta.org/) to be much friendlier to beginners, but it may not be as easy to integrate. It also uses it's own api rather than the ev3dev-python api, and the generated Python code isn't editable.

I'll look at this issue again when I have the time. For now, I'll like to spend what little free time I have on the back-end. But if anyone's keen to take this up, they'll have my full support.

psychemedia commented 4 years ago

@QuirkyCort As you say, I think the RobertaLab editor just maps from blocks to code, whereas the BlockMirror one goes both ways.

There is an old embeddable blockly style editor for Jupyter notebooks — https://github.com/Calysto/metakernel/blob/master/examples/Jigsaw%20in%20IPython.ipynb — but I don't recall offhand what it uses as a parser. IIRC, you can generate and export code to a Jupyter code cell, but not vice versa. It's also quite old, so I suspect the way is does that is a fudge, rather than offering the state mirroring between py and JS that more recent versions of ipywidgets supports.

QuirkyCort commented 4 years ago

I've been working on a 3D successor to the 2D simulator. You can find it here. https://gears.aposteriori.com.sg/

Among other things, it provides a blocks coding interface using Blockly that auto-converts to Python. It's not ready for use yet, but you can play around with it and see what breaks. There are no Python-to-blocks conversion, but that may be added in the future. There are still a lot to do now, so I can't commit to when I'll look into that.