I am trying to create a function inside a class and with this function, I want to calculate how many checkboxes clicked.
#This function assesses number of clicked items in my class's list
def badper(self):
window=Tk()
window.config(bg='lightgreen')
# total = 0
def show(self):
new_label = Label(window, text=var.get()).pack()
var=IntVar()
def create_check_button(self,i):
var = IntVar()
c=Checkbutton(window,text=self.badcharacter[i],variable=var)
c.pack()
# if c == 1:
# global total
# total += 1
#This loop creates checkboxes in the equivalent of number items of my list
for i in range(6):
create_check_button(self,i)
#This button should show how many items clicked so far
my_button=Button(window,text="show", font=("Arial", 12, "bold"),command=show(self)).pack()
Another related question is the IntVar()
does not show 0,1 when I write the code below:
def badper(self):
window=Tk()
window.config(bg='lightgreen')
def show():
my_label=Label(window,text=var.get()).pack()
var=IntVar()
c = Checkbutton(window, text="abc", variable=var)
c.deselect()
c.pack()
my_button = Button(window, text="show", font=("Arial", 12, "bold"), command=show).pack()