2018-09-27 09:18:35 +00:00
|
|
|
#PySimple examples (v 3.8)
|
|
|
|
#Tony Crewe
|
2018-11-13 15:33:55 +00:00
|
|
|
#Oct 2018 MacOs
|
2018-09-27 09:18:35 +00:00
|
|
|
|
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
|
|
|
sg.SetOptions (background_color = 'LightBlue',
|
|
|
|
element_background_color = 'LightBlue',
|
|
|
|
text_element_background_color = 'LightBlue',
|
2018-11-13 15:33:55 +00:00
|
|
|
font = ('Arial', 12, 'bold'),
|
2018-09-27 09:18:35 +00:00
|
|
|
text_color = 'Blue',
|
|
|
|
input_text_color ='Blue',
|
2018-11-13 15:33:55 +00:00
|
|
|
button_color = ('Blue', 'White')
|
2018-09-27 09:18:35 +00:00
|
|
|
)
|
|
|
|
#update (via list) values and and display answers
|
|
|
|
#value[0] is celcius input, value[1] is input to place result.
|
|
|
|
#Use ReadButton with while true: - keeps window open.
|
|
|
|
|
|
|
|
layout = [ [sg.Text('Enter a Temperature in Celcius')],
|
|
|
|
[sg.Text('Celcius', size =(8,1)), sg.InputText(size = (15,1))],
|
|
|
|
[sg.Text('Result', size =(8,1)), sg.InputText(size = (15,1))],
|
2018-10-08 05:36:38 +00:00
|
|
|
[sg.ReadButton('Submit', bind_return_key = True)]]
|
|
|
|
#Return = button press
|
2018-09-27 09:18:35 +00:00
|
|
|
window = sg.Window('Converter').Layout(layout)
|
|
|
|
|
|
|
|
while True:
|
2018-10-08 05:36:38 +00:00
|
|
|
#get result
|
|
|
|
button, value = window.Read()
|
|
|
|
#break out of loop is button not pressed.
|
|
|
|
if button is not None:
|
2018-09-27 09:18:35 +00:00
|
|
|
fahrenheit = round(9/5*float(value[0]) +32, 1)
|
2018-10-08 05:36:38 +00:00
|
|
|
#put result in 2nd input box
|
|
|
|
window.FindElement(1).Update(fahrenheit)
|
2018-09-27 09:18:35 +00:00
|
|
|
else:
|
|
|
|
break
|