jeudi 1 décembre 2016

check box, when i tick the box the value of var does not change to 1

When i click on the check box i want the value of var to change to 1 however when i var.get() in a function the value always comes up as 0.

var1 = IntVar()
tickbox_1 = Checkbutton(custom,text=label_1,
                                variable=var1,)
        tickbox_1.grid(row=2,column=1)

i have a function that is called by a button which gets the value of var1 and prints it.

def custom_create():
     print(var1.get())

anything i can do to make sure that var1 becomes 1 when the box is ticked. Also how can i get the box ticked when the window launches?




Aucun commentaire:

Enregistrer un commentaire