I have a widget in kv lang:
<FileWidget>:
canvas.before:
Rectangle:
size: self.size
pos: self.pos
size_hint: None, None
size: 49, 75
pos_hint: {'x':0,'center_y': 0.5}
I am loading the file in python using Builder.
Then I am importing using 'from <kv filename> import FileWidget
Then I am trying to update the source of the rectangle in python:
file_image = FileWidget(…)
I can change its size using:
file_image = FileWidget(size=(49, 75))
But cannot update the canvas.before, Rectangle, source path.
I have tried using:
with file_image.canvas.before:
Rectangle(source='filename.png')
But this adds a new rectangle and does not update the source of the existing one.
Is there a way to update the existing rectangle?
Thanks.