I am creating a Kivy app. I am fetching some data like names, email adress and so on from an sql table. depending on how many entrys are found depending on the searched name i want to dynamicly create card widgets. This works fine for now. I want to add a function to click on a widget to edit the data from this entry. But I am unable to assign an id or something to the card widget to check which widget is pressed.
This is part of my function in Main class
for i, _ in enumerate (records):
label=MDCard(padding= 4, md_bg_color= self.theme_cls.primary_color, size=( 200, 210), size_hint=(None, None))
label2=GridLayout(rows=8, cols=2,orientation= "lr-tb")
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][1])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][2])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][3])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][4])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][5])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][6])))
label2.add_widget(MDIcon(icon='cash'))
label2.add_widget(MDLabel(text=str(records[i][7])))
label.add_widget(label2)
self.root.ids.testscreen.add_widget(label)
this code creates my card widgets. I googled for several hours but cant get a solution.
I want something like label.bind (on_press = clicked_card(i))
def clicked_card(i): print(i)
I am very new to python and Kivy and hope someone can help me to find a solution.