0

I am working on a visual programming tool based on drag-and-drop components. We are currently able to generate working Python code from our graphical components (each component is a class). The graphical components are connected via arrows and each of them have a settings window with drop-downs, checkboxes, etc for detailed configuration.

Now, we want to do the opposite and let users edit the code and have these changes reflected in the graphical components.

We have been pondering a few different solutions:

  • parsing the code. This seems quite brittle (variable names can change, assignments can happen in conditionals, etc)
  • adding abstract properties to each rendered component
  • passing a configuration object to each rendered component

My intuition as a developer says that the latter two are the most feasible and robust solutions, but I am having difficulties putting my concerns into words that would resonate with the stakeholders.

A related problem on the same topic: we are also looking at the prospect of taking "any" code written from scratch by a user and converting that into graphical components. That is, code that uses the same 3rd party frameworks as we do, but isn't necessarily written with our framework in mind.

Which factors should be taken into consideration when estimating the complexity in such tasks? Are there any success/horror stories on these topics that I could study?

mrak
  • 41
  • 3
  • This is too vague to really answer, but if the users can edit the code, surely you need to parse it after edit (unless you put severe limits on the nature of the edits). Perhaps the `ast` module would suffice for the parsing. – John Coleman May 23 '20 at 17:05
  • If you are going from Python to your unspecified visual programming language, you are in effect talking about writing a translator between two different programming languages. Sounds highly non-trivial, unless you only want to be able to translate a small subset of Python. – John Coleman May 23 '20 at 17:21
  • We're targeting a special niche where we're creating a visual abstraction with Python under the hood, so every component has a small initial number of properties. I've been considering the ast module, but I'm afraid that it would easily spiral out of control and become a maintenance horror. The idea is very similar to [Unreal Engine Blueprint scripting](https://forums.unrealengine.com/filedata/fetch?id=1166342&d=1446673216). They generate C++ code from visual components. I don't think they let users go back and forth, though. – mrak May 23 '20 at 17:50

0 Answers0