dimanche 2 octobre 2016

Python, Passing and updating values of a list through GUI(checkboxes)

I have 6 checkboxes in a GUI i have made.

chk_b = [0, 0, 0, 0, 0, 0] #Create a list to hold 6 buttons 

chk_0 = Checkbutton(window, text = "Technology", command = check_button(0)) #FirstCheckButton
chk_0.pack()

When the check button is pressed it passes the value 0 to the function check_button which basically denotes that its the first check button in the list.

def check_button(type_button): 
    global chk_b  
    chk_b[type_button] == 1

The problem I'm having is that when i print through all my values after I've checked a checkbox they are all still equal to 0.

Aucun commentaire:

Enregistrer un commentaire