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