Slider change_submits feature. Update method for Slider, updated Font Sizer demo
This commit is contained in:
parent
b7c095d9c0
commit
3793ff81c2
2 changed files with 33 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
|
||||
# Testing async form, see if can have a spinner
|
||||
# Testing async form, see if can have a slider
|
||||
# that adjusts the size of text displayed
|
||||
|
||||
import PySimpleGUI as sg
|
||||
|
@ -8,8 +8,10 @@ form = sg.FlexForm("Font size selector")
|
|||
|
||||
fontSize = 12
|
||||
sampleText = sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontSize))
|
||||
slider = sg.Slider(range=(6,50), orientation='h', size=(10,20), change_submits=True, key='slider')
|
||||
spin = sg.Spin([sz for sz in range(4,72)], font=('Helvetica 20'), initial_value=fontSize, change_submits=True, key='spin')
|
||||
layout = [
|
||||
[sampleText, sg.Spin([sz for sz in range(4,72)], font=('Helvetica 20'), initial_value=fontSize, change_submits=True, key='spin')],
|
||||
[sampleText, spin, slider],
|
||||
[sg.OK(), sg.Cancel()]
|
||||
]
|
||||
|
||||
|
@ -19,10 +21,15 @@ while True:
|
|||
button, values= form.Read()
|
||||
if button is None:
|
||||
break
|
||||
sz = int(values['spin'])
|
||||
sz_spin = int(values['spin'])
|
||||
sz_slider = int(values['slider'])
|
||||
sz = sz_spin if sz_spin != fontSize else sz_slider
|
||||
if sz != fontSize:
|
||||
print(sampleText.Font, sampleText.Size)
|
||||
fontSize = sz
|
||||
font = "Helvetica " + str(fontSize)
|
||||
sampleText.Update(font=font)
|
||||
slider.Update(sz)
|
||||
spin.Update(sz)
|
||||
|
||||
print("Done.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue