2018-09-27 09:18:35 +00:00
|
|
|
#PySimple examples (v 3.8)
|
|
|
|
#Tony Crewe
|
|
|
|
#Sep 2018
|
|
|
|
|
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
|
|
|
#Set formatting options for all elements rather than individually.
|
|
|
|
sg.SetOptions (background_color = 'LightBlue',
|
|
|
|
element_background_color = 'LightBlue',
|
|
|
|
text_element_background_color = 'LightBlue',
|
|
|
|
font = ('Arial', 10, 'bold'),
|
|
|
|
text_color = 'Blue',
|
|
|
|
input_text_color ='Blue',
|
|
|
|
button_color = ('White', 'Blue')
|
|
|
|
)
|
|
|
|
#adjust widths
|
|
|
|
layout = [
|
|
|
|
[sg.Text('Celcius', size =(12,1)), sg.InputText(size = (8,1))],
|
2018-09-28 18:57:37 +00:00
|
|
|
[sg.Submit()]
|
2018-09-27 09:18:35 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
window = sg.Window('Converter').Layout(layout)
|
|
|
|
button, value = window.Read()
|
2018-11-13 15:33:55 +00:00
|
|
|
if button is None:
|
|
|
|
#windows was closed without button being pressed
|
|
|
|
exit(0)
|
2018-09-27 09:18:35 +00:00
|
|
|
fahrenheit = round(9/5*float(value[0]) +32, 1)
|
|
|
|
result = 'Temperature in Fahrenheit is: ' + str(fahrenheit)
|
|
|
|
sg.Popup('Result',result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|