0
I’m learning how to use Simplepythongui, but I’m encountering a bug. The problem is this: when I get to if
down there, even if the number random
and the one chosen by the user are equal, the program does not give the print
that the user has won and always goes to the else
.
import PySimpleGUI as pg
from random import randint
class telapython:
def __init__(self):
#layout
layout = [
[pg.Text('Digite um número') , pg.Input(key= 'Pergunta')],
[pg.Button('Verificar número')],
]
#janela
janela = pg.Window('Adivinhe o número').layout(layout)
#extração de dados
self.button , self.values = janela.Read()
def iniciar(self):
random = randint(0, 1)
pergunta = self.values['Pergunta']
print(random , pergunta)
if random == pergunta:
print('Você venceu')
else:
print('Você errou')
tela = telapython()
tela.iniciar()