0
help with a program in tkinter
I am making a counter program in which every time I touch the "+" button it has to increase the number that is displayed after the "counter:" label, but I can only make it increase from 0 to 1 and it does not increase anything else. I am new to graphical interfaces. My code: from tkinter import * def sumar(): resultado.set(numero+1) root=Tk() root.title("Contador") numero=0 resultado=IntVar() Label(root,text="Contador:").grid(row=0,column=0) Entry(root,justify=CENTER,state="disable",textvariable=resultado).grid(row=0,column=1) Button(root,text="+",command=sumar).grid(row=0,column=2) root.mainloop()
3 Réponses
+ 5
Because you are not incrementing Numero variable
Numero + 1 will always be 1
Because Numero variable has 0 in it
0
Ohhhh i see
0
Thank you very much