From b7c095d9c01a758945b4d0bb14a50c77d08b9969 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 31 Aug 2018 09:10:15 -0400 Subject: [PATCH] New demo that shows how to use new spinner change submits capability --- Demo_Font_Sizer.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Demo_Font_Sizer.py diff --git a/Demo_Font_Sizer.py b/Demo_Font_Sizer.py new file mode 100644 index 00000000..452e22b5 --- /dev/null +++ b/Demo_Font_Sizer.py @@ -0,0 +1,28 @@ + +# Testing async form, see if can have a spinner +# that adjusts the size of text displayed + +import PySimpleGUI as sg + +form = sg.FlexForm("Font size selector") + +fontSize = 12 +sampleText = sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontSize)) +layout = [ + [sampleText, sg.Spin([sz for sz in range(4,72)], font=('Helvetica 20'), initial_value=fontSize, change_submits=True, key='spin')], + [sg.OK(), sg.Cancel()] + ] + +sz = fontSize +form.Layout(layout) +while True: + button, values= form.Read() + if button is None: + break + sz = int(values['spin']) + if sz != fontSize: + fontSize = sz + font = "Helvetica " + str(fontSize) + sampleText.Update(font=font) + +print("Done.")