Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: how to use ui for (*custom*) python code generation? #459

Open
s-light opened this issue Mar 29, 2024 · 2 comments
Open

question: how to use ui for (*custom*) python code generation? #459

s-light opened this issue Mar 29, 2024 · 2 comments

Comments

@s-light
Copy link

s-light commented Mar 29, 2024

hello community,

i would like to experiment with this flow-graph ui embedded in a CircuitPython web-editor.
so my target output are python files.

on my current looking into this package i do not have an idea how to start with this..
for my use-case i can not use a live / play mode -
i think more of a every time a changes is made i regenerate the code -
so i need some kind of code-fragment-generation for every node...
would it be a good idea to just use the onExecute function to append the code-fragment?
(i know i would have to write a a lots of nodes to have all the basic python language parts available..)

or does anybody knows of a visual similar maintained library/framework that has python code generation already implemented?
maybe there is a fundamental other concept / idea how to go about such an idea..

in the end i would love to have both: flow-graph to code | code to flow-graph
so aim also very open to any comments / ideas...

@EliCDavis
Copy link

I am not sure if this is helpful for your use case, but I am working on a code => flow-graph. Currently working on the other direction (and is considerably harder IMO).

Node definition begins with at best I can describe as inheritance (not really a thing in golang). You can see an example of this here
https://github.com/EliCDavis/polyform/blob/main/examples/edit-gaussian-splats/main.go#L55

This requires a ton of reflection to then transform it into a node when it comes to javascript, which comes down to a switch statement based on the type of data it's dealing with
https://github.com/EliCDavis/polyform/blob/main/generator/html/js/nodes/node.js#L10

Luckily being in python, you don't really need to deal with reflection, which might make the flow-graph => code aspect easier.

I don't use onExecute ever. I subscribe to node creation/deletion/connection editing.

@s-light
Copy link
Author

s-light commented Apr 2, 2024

Thanks EliCDAvis!

that are nice hints and concept points!

do you know of the BlockMirror project?
it does python → blocks (blockly)
they are using

Skulpt: A Python-to-Javascript transpiler. We use it for its parser.

they parse the python to an Abstract Syntax Tree (AST) and from this generate the blocks.
i did not dig deeper in the how all of this works ;-)

for now i have to lay this project idea on ice..
(it is just to complex for me / to much other things needing my attention)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants