PySimpleGUI/ProgrammingClassExamples/1a PSG (Entry and PopUp).py

34 lines
626 B
Python

#PySimple examples (v 3.8)
#Tony Crewe
#Sep 2018
import PySimpleGUI as sg
#layout, Text, Input,button on line below
layout = [
[sg.Text('Celcius'), sg.InputText()],
[sg.Submit()],
]
#setup window with Title
window = sg.Window('Temperature Converter').Layout(layout)
#get value (part of a list)
button, value = window.Read()
#convert and create string
fahrenheit = round(9/5*float(value[0]) +32, 1)
result = 'Temperature in Fahrenheit is: ' + str(fahrenheit)
#display in Popup
sg.Popup('Result', result)