Search on blog:

Kivy: how to access widget's id defined in KV lang using string in Python code

Kivy allows to use .ids["name"] instead of .ids.name

And this allows to use string formatting to create string with name

.ids[f"label_{i}"].text

.ids["label_{}".format(i)].text

.ids["label_%s" % i].text

In documentation Accessing Widgets defined inside Kv lang in your Python code you can see example code with comment "alternative syntax"

self.ids.hulk.text = "hulk: puny god!"
self.ids["loki"].text = "loki: >_<!!!"  # alternative syntax

ids is dictionary type property and you can iterate it

for key, val in self.ids.items():
    print("key={0}, val={1}".format(key, val))
If you like it
Buy a Coffee