PySimpleGUI/Demo_Font_Sizer.py

27 lines
1.0 KiB
Python
Raw Normal View History

# Testing async form, see if can have a slider
# that adjusts the size of text displayed
import PySimpleGUI as sg
fontSize = 12
2018-09-04 04:30:29 +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')]]
sz = fontSize
window = sg.Window("Font size selector", grab_anywhere=False)
window.Layout(layout)
while True:
button, values= window.Read()
2018-09-23 16:16:50 +00:00
if button is None or button == 'Quit':
break
sz_spin = int(values['spin'])
sz_slider = int(values['slider'])
sz = sz_spin if sz_spin != fontSize else sz_slider
if sz != fontSize:
fontSize = sz
font = "Helvetica " + str(fontSize)
window.FindElement('text').Update(font=font)
window.FindElement('slider').Update(sz)
window.FindElement('spin').Update(sz)
print("Done.")