import PySimpleGUI as sg
# Tema
sg.theme('DarkGrey10')
# Layout
layout = [
[sg.Text('Digite seu nome:')],
[sg.Input(key='nome')],
[sg.Text('Digite sua idade:')],
[sg.Input(key='idade')],
[sg.Button(button_text = 'Ok')]
]
# Janela
window = sg.Window('Tela de Cadastro', layout=layout)
#Leitura e eventos de valores
while True:
event,values = window.read()
#ler e reagir aos eventos
if event == sg.WIN_CLOSED:
break
elif event == 'Ok':
print('Você clicou ok')
nome = values['nome']
idade = values['idade']
if nome and idade == None:
print('Precisa preencher os campos!')
else:
print(f'O {nome} tem {idade} anos de idade:')
Editor is loading...