I created multiple checkbuttons using a for loop from a list of names. Since there are more than 500 names, I wanted to use the for loop instead of typing them one by one. I need to find out which names are selected from these checkbuttons. But no matter what I did, I couldn't get the values of the checkbuttons one by one. In some of my attempts, I got a single numeric value, but I couldn't get a value for each checkbutton. I don't know where I am doing wrong. Can I get each value from inside this loop? Or do I have to write them all one by one?
## a list as an example (There are more than 500 people on the original list.)
name_list = ['John Smith', 'Granny Smith', 'Michael Smith', 'Big Smith', 'Hello Smith']
for record in name_list:
nameVar = IntVar()
cb_name = Checkbutton(root, text=record, variable=nameVar, bg="white", anchor="w")
cb_name.pack(fill="both")