-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy path1c PSG (persistent form and bind key).py
35 lines (31 loc) · 1.18 KB
/
1c PSG (persistent form and bind key).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#PySimple examples (v 3.8)
#Tony Crewe
#Oct 2018 MacOs
import FreeSimpleGUI as sg
sg.SetOptions (background_color = 'LightBlue',
element_background_color = 'LightBlue',
text_element_background_color = 'LightBlue',
font = ('Arial', 12, 'bold'),
text_color = 'Blue',
input_text_color ='Blue',
button_color = ('Blue', 'White')
)
#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))],
[sg.ReadButton('Submit', bind_return_key = True)]]
#Return = button press
window = sg.Window('Converter').Layout(layout)
while True:
#get result
button, value = window.Read()
#break out of loop is button not pressed.
if button is not None:
fahrenheit = round(9/5*float(value[0]) +32, 1)
#put result in 2nd input box
window.FindElement(1).Update(fahrenheit)
else:
break