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()

7th May 2021, 6:35 PM
Yami Francø
Yami Francø - avatar
3 Respostas
+ 5
Because you are not incrementing Numero variable Numero + 1 will always be 1 Because Numero variable has 0 in it
7th May 2021, 6:48 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
Ohhhh i see
7th May 2021, 6:50 PM
Yami Francø
Yami Francø - avatar
0
Thank you very much
7th May 2021, 6:51 PM
Yami Francø
Yami Francø - avatar