Programming course with PySimpleGUI lessons
This commit is contained in:
parent
78c31358be
commit
8b4185988f
12 changed files with 582 additions and 0 deletions
40
ProgrammingClassExamples/3 PSG (multiline display).py
Normal file
40
ProgrammingClassExamples/3 PSG (multiline display).py
Normal file
|
@ -0,0 +1,40 @@
|
|||
#PySimple examples (v 3.8)
|
||||
#Tony Crewe
|
||||
#Sep 2018
|
||||
|
||||
import PySimpleGUI as sg
|
||||
|
||||
sg.ChangeLookAndFeel('GreenTan')
|
||||
|
||||
sg.SetOptions(font = ('Courier New', 12))
|
||||
|
||||
|
||||
|
||||
layout = [
|
||||
[sg.Text('Enter and Add Data to Display', font = ('Calibri', 14,'bold'))],
|
||||
[sg.Text('Race:', size = (5,1)), sg.InputText(size = (8,1)),
|
||||
sg.Text('Club:', size = (5,1)), sg.InputText(size = (8,1))],
|
||||
[sg.Text('Name:', size = (5,1)), sg.InputText(size = (8,1)),
|
||||
sg.Text('Time:', size = (5,1)), sg.InputText(size = (8,1)),sg.Text(' '),
|
||||
sg.ReadButton('Add Data', font = ('Calibri', 12, 'bold'))],
|
||||
[sg.Text('_'*40)],
|
||||
[sg.Text(' Race Club Name Time')],
|
||||
[sg.Multiline(size =(40,6),key = 'Multiline')]
|
||||
]
|
||||
|
||||
window = sg.Window('Enter & Display Data').Layout(layout)
|
||||
|
||||
string = ''
|
||||
S=[]
|
||||
while True:
|
||||
|
||||
button, value = window.Read()
|
||||
if button is not None:
|
||||
#use string formatting - best way? plus Courier New font - non-proportional font
|
||||
S = S + ['{:^9s}{:<11s}{:<10s}{:>8s}'.format(value[0],value[1],value[2],value[3])]
|
||||
for s in S:
|
||||
string = string + s + '\n'
|
||||
window.FindElement('Multiline').Update(string)
|
||||
string =''
|
||||
else:
|
||||
break
|
Loading…
Add table
Add a link
Reference in a new issue