Insert checkboxes programatically

I would like to insert checkboxes programatically, like so:

   for item in zip(players,teams):
       image = Image.open(f'collect/images/players_40x40/{item[0]}.png')
       st.image(image)
       st.text(f'{item[0]} ({item[1]})')
       if st.checkbox('Know more about this player'):
          # do something

But although st.images(image) works, st.checkbox() appears only below the first item. any ideas?

oh, the problem is check box was using the same key fot all iterations. once I inserted a variable and did:

more_stats = st.checkbox(f'Know more about {item[0]}')
if more_stats:
   #show

It worked.

1 Like