0
from tkinter import *
from random import randrange, uniform
window = Tk()
window.title("Welcome to LikeGeeks app")
window.geometry('800x600')
lbl1 = Label(window, text="00", font=("Arial Bold", 50))
lbl1.grid(column=0, row=0)
lbl2 = Label(window, text="00", font=("Arial Bold", 50))
lbl2.grid(column=0, row=1)
lbl3 = Label(window, text="+", font=("Arial Bold", 50))
lbl3.grid(column=3, row=0)
resposta = Entry(window,width=4, font=("Arial Bold", 50))
resposta.grid(column=0, row=2)
def proxima():
a = randrange(10, 99) #faixa de inteiro
b = randrange(10, 99) #faixa de inteiro
lbl1.configure(text= str(a))
lbl2.configure(text= str(b))
soma = a+b
print(soma)
def calculo():
print(soma)
if resposta.get() == soma:
print("Acertou")
else:
print("Errou...")
btn = Button(window, text="Proxima", command=proxima)
btn.grid(column=0, row=3)
btn2 = Button(window, text="Calcular", command=calculo)
btn2.grid(column=0, row=4)
window.mainloop()
Relate the item
Thanks friend! Even without understanding you gave me the answer I needed, "global sum", worked the way I wanted!
– Henrique Pagan