0

I have a problem with the following part of my code, I have a function that is responsible for generating several containers where data such as the name and surname of the people are located, and also their identity card, all this data is extracted from a database , all good so far, the code runs perfectly and shows all the records correctly, the problem is that each container can be Clicked on and they call a function that at times only prints the data displayed from the containers, but when you step on any container prints the data from the last container.

def generarCards(self, pagee):
    pagee = pagee

    cartas = []

    querySelectJefe = "SELECT nombre, apellido, ci FROM jefesf"
    resultado = logica.consulta(querySelectJefe)

    for nom, ape, ci in resultado:
        cartas.append(
            Container(
                 bgcolor="RED",
                 height=150,
                 width=250,
                 border_radius=border_radius.all(20),
                 on_click=lambda _: self.seleccionarJefe(ci),
                 content=Column(
                     controls=[
                         Text(f"{nom} {ape}"),
                         Text(f"{ci}"),
                     ]
                 )
             )
         )
         pagee.update()

     return cartas

This is the function that prints the data:

 def seleccionarJefe(self, jefe):
      jefe = jefe

      print(jefe)

I don't know why the data of the last container is always printed, if someone can help me, I thank you in advance.

0 Answers0