Continuing this thread:
Using KiCad version 5.1.9
I continued working on this, and it is mostly working, but missing one crucial part.
When drawing a polygon or zone in rectangular, axis-aligned shape (4 points exactly) ontho the PCB on a slik or copper layer in PCBnew, the script loads that PCB from file, replaces the rectangles with a pre-generated “qr.png” image.The nsaves that to a new *.kicad_pcb file.
What is missing:
A way to specify for each template rectangle, what it should be replaced with. My initial idea was, to use a key-value pair, or if not available, abuse a name or description property to store the path to the image that should be placed there. Sadly, neither DRAWSEGMENT nor ZONE_CONTAINER have any such thing. In python code, it is possible to create a MODULE, give it a name or description, and add polygon or zone into that, but I would not know how to do that in the KiCad GUI.
Do I have ot make a custom GUI plugin that allows the user to do that.
If all else fails, I will somehow have to limit the functionality to a single image which one has to feed directly to my script when invoking it, which would not be so nice.
Any ideas, tips, links to solutions for similar problems (or GUI plugins), maybe?