Thank you for this example on how to use:
index_x = parent_widget.children.index(a_child_widget)
Here is how it looks in my app:
def replace_button_with_label(self):
index_b = self.children.index(self.choose_first_target_button)
self.remove_widget(self.children[index_b])
self.target_text_label = ScalableLabel()
self.set_target_label_text()
self.add_widget(self.target_text_label, index=index_b)
And here is a minimal example on how to replace a Button with a Label:
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
box = BoxLayout(orientation='vertical')
lab1 = Label(text="Text-1")
but = Button(text="Touch me") # NOT butt...
lab3 = Label(text="Text-3")
box.add_widget(lab1)
box.add_widget(but)
box.add_widget(lab3)
index_b = box.children.index(but)
print(index_b)
lab2 = Label(text="Text-2")
box.remove_widget(box.children[index_b])
box.add_widget(lab2, index=index_b)