1
I would like to know how to do when click the reply button, restart the program with a new account and optimizing the code?
from tkinter import*
from random import randrange
janela=Tk()
janela.geometry('100x80')
janela.resizable(0,0)
a=(randrange(0,9))
b=(randrange(0,9))
def solucao():
if float(campoResposta.get()) == a+b:
#print('Correto!')
rotuloSolucao['text'] = 'Correto!'
else:
#print('Errado')
rotuloSolucao['text'] = 'Errado!'
limpar()
def limpar():
campoResposta.delete(first=0,last=10)
rotuloQuestao = Label(janela, text='Quanto é {} + {}: '.format(a,b),bg='green')
rotuloQuestao.pack(fill=X)
campoResposta = Entry()
campoResposta.pack()
botaoResponder= Button(janela,text='Responder', command=solucao)
botaoResponder.pack()
rotuloSolucao = Label(bg='yellow')
rotuloSolucao.pack(fill=X)
janela.mainloop()