Hi, here I am trying to create some annotation tool on my user interface to locate defects on a part.
My idea was to create an xy container with an onClick event. I get the x/y coordinate of that event and then add a tiny red label at that position in the container.
Ultimately I store all this in a table so I can delete / modify this labels later on.
So I try to make it block by block:
- Getting event location, no problem.
- Adding a new label in container... problem
My idea in that was: I create an example label, copy and paste that in vs code to understand that structure, and put that again in my script using child.append in my container, below my code, as you can guess it does not work. Runs without alarms, but new_point is not added.
Any idea how I could add an object as child to my container?
#Below my code
def runAction(self, event):
# read coordinate
x = event.pageX
y = event.pageY
# Test adding a second point
new_point = {
"type": "ia.display.label",
"version": 0,
"props": {
"style": {
"background-color": "red"
}
},
"meta": {
"name": "new_point"
},
"position": {
"x": 10,
"y": 10,
"height": 5,
"width": 5
},
"custom": {}
}
# childs reading before
for child in self.getChildren():
system.perspective.print(child.meta.name)
# append new point
self.children.append(new_point)
# check it out
for child in self.getChildren():
system.perspective.print(child.meta.name)