Skip to content

Instantly share code, notes, and snippets.

@MikeTheWatchGuy
Created October 13, 2018 21:30
Show Gist options
  • Select an option

  • Save MikeTheWatchGuy/6d64f9f9b8ef7ae805d68c942850b19f to your computer and use it in GitHub Desktop.

Select an option

Save MikeTheWatchGuy/6d64f9f9b8ef7ae805d68c942850b19f to your computer and use it in GitHub Desktop.
import PySimpleGUI as sg
layout = [[sg.Text('Add 2 Numbers', font='Helvetica 15')],
[sg.InputText(size=(8,1) ,key='in1'), sg.Text(' + '), sg.Input(size=(8,1), key='in2'),sg.Text('',key='answer')],
[sg.Text('')],
[sg.ReadButton('Add')]]
window = sg.Window('Add 2 numbers').Layout(layout)
# event loop
while True:
button, values = window.Read()
if button is None:
break
num1 = int(values['in1'])
num2 = int(values['in2'])
answer = num1+num2
window.FindElement('answer').Update(answer)
@MikeTheWatchGuy

Copy link
Copy Markdown
Author

snag-0073

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment