2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-08-31 13:10:15 +00:00
|
|
|
|
2018-08-31 13:29:00 +00:00
|
|
|
# Testing async form, see if can have a slider
|
2018-08-31 13:10:15 +00:00
|
|
|
# that adjusts the size of text displayed
|
|
|
|
|
|
|
|
fontSize = 12
|
2019-10-23 20:10:03 +00:00
|
|
|
layout = [
|
|
|
|
[sg.Spin([sz for sz in range(6, 172)],
|
|
|
|
font=('Helvetica 20'),
|
|
|
|
initial_value=fontSize,
|
|
|
|
change_submits=True, key='spin'),
|
|
|
|
sg.Slider(range=(6, 172), orientation='h', size=(10, 20), change_submits=True, key='slider',
|
|
|
|
font=('Helvetica 20')),
|
|
|
|
sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontSize), key='text')]
|
|
|
|
]
|
2018-08-31 13:10:15 +00:00
|
|
|
sz = fontSize
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window("Font size selector", layout, grab_anywhere=False)
|
2018-08-31 13:10:15 +00:00
|
|
|
while True:
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
2018-10-15 20:07:23 +00:00
|
|
|
if event is None or event == 'Quit':
|
2018-08-31 13:10:15 +00:00
|
|
|
break
|
2018-08-31 13:29:00 +00:00
|
|
|
sz_spin = int(values['spin'])
|
|
|
|
sz_slider = int(values['slider'])
|
2019-10-23 20:10:03 +00:00
|
|
|
|
2018-08-31 13:29:00 +00:00
|
|
|
sz = sz_spin if sz_spin != fontSize else sz_slider
|
2019-10-23 20:10:03 +00:00
|
|
|
|
2018-08-31 13:10:15 +00:00
|
|
|
if sz != fontSize:
|
|
|
|
fontSize = sz
|
|
|
|
font = "Helvetica " + str(fontSize)
|
2019-10-23 20:10:03 +00:00
|
|
|
window['text'].update(font=font)
|
|
|
|
window['slider'].update(sz)
|
|
|
|
window['spin'].update(sz)
|
2018-08-31 13:10:15 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window.close()
|