Hi all,
I am creating widgets on-the-fly using Factory.MyWidget() and positioning them on a FloatLayout using pos_hint
These widgets are small circular images used as breadcrumbs as I fly across a terrain.
I want to connect these breadcrumbs with lines.
Line: takes a list of pixel coordinates (and not a pos_hint) so I need to get the actual x and y coordinates of the breadcrumb images.
I can easily get the x and y from image widgets that are explicitly defined in the .kv file by using their id
For example:
self.rStartx = self.ids.GraphicStart.x + self.ids.GraphicStart.width / 2
...but I can't get them for the widgets created on-the-fly.
When I create my breadcrumbs I give them a unique id using the date and time:
MyImageWidget = Factory.MyImage()
MyImageWidget.id = time.strftime("%Y%m%d%H%M%S")
...
self.ids.MainFloatLayout.add_widget(MyImageWidget,3)
self.WidgetListImage.append(MyImageWidget)
Then I would expect to be able to get the x and y coordinates like this:
for breadcrumb in self.WidgetListImage:
pointx = self.ids[
breadcrumb.id].x
pointy = self.ids[
breadcrumb.id].y
and from this, construct a list of tuples to build the line.
The problem is that self.ids[
breadcrumb.id].x throws a KeyError exception
File "main.py", line 3013, in updateGFD
pointx = self.ids[
breadcrumb.id].x
KeyError: '20150502014155'
I've been wrestling with this problem for hours. Can anyone show me where I am going wrong???
Thanks in advance,
Dave