Hello
I'm trying to determine the states of checkboxes depending whether or not they had been checked the previous time the programme was run. I do not know what i'm doing wrong.
Thank you.
I'm trying to determine the states of checkboxes depending whether or not they had been checked the previous time the programme was run. I do not know what i'm doing wrong.
from tkinter import * to_do_list = ['a', 'b', 'c', 'd'] already_done = [] fh = open('mem.txt', 'r') for line in fh: already_done.append(line[:-1]) class checker(): global already_done def __init__(self, root, name): self.root = root self.name = name if self.name in already_done: self.CheckVar = IntVar(value=1) else: self.CheckVar = IntVar(value=0) self.checkbutton = Checkbutton(self.root, text = name, variable = self.CheckVar) self.checkbutton.pack() root = Tk() for item in to_do_list: c = checker(root, item) root.mainloop()Inputs please :)
Thank you.