How do I create multiple checkboxes from a list in a for loop in python tkinter
问题 I have a list of variable length and want to create a checkbox (with python TKinter) for each entry in the list (each entry corresponds to a machine which should be turned on or off with the checkbox -> change the value in the dictionary). print enable {'ID1050': 0, 'ID1106': 0, 'ID1104': 0, 'ID1102': 0} (example, can be any length) now the relevant code: for machine in enable: l = Checkbutton(self.root, text=machine, variable=enable[machine]) l.pack() self.root.mainloop() This code produces