Programming course with PySimpleGUI lessons
This commit is contained in:
parent
78c31358be
commit
8b4185988f
12 changed files with 582 additions and 0 deletions
29
ProgrammingClassExamples/1a PSG (Entry and PopUp).py
Normal file
29
ProgrammingClassExamples/1a PSG (Entry and PopUp).py
Normal file
|
@ -0,0 +1,29 @@
|
|||
#PySimple examples (v 3.8)
|
||||
#Tony Crewe
|
||||
#Sep 2018
|
||||
|
||||
import PySimpleGUI as sg
|
||||
|
||||
layout = [
|
||||
[sg.Text('Celcius'), sg.InputText()], #layout, Text, Input
|
||||
[sg.Submit()], #button on line below
|
||||
]
|
||||
|
||||
#setup window with Title
|
||||
window = sg.Window('Temperature Converter').Layout(layout)
|
||||
|
||||
button, value = window.Read() #get value (part of a list)
|
||||
|
||||
fahrenheit = round(9/5*float(value[0]) +32, 1) #convert and create string
|
||||
result = 'Temperature in Fahrenheit is: ' + str(fahrenheit)
|
||||
sg.Popup('Result', result) #display in Popup
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue