From a56cdb97359427cad78707f4bee75589bd72dfb4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 10 Sep 2018 20:20:15 -0400 Subject: [PATCH 1/2] Fix in Spinner update. Wasn't working in forms that returned on change --- PySimpleGUI.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 273018d8..1634cf1e 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -551,14 +551,16 @@ class Spin(Element): return def Update(self, new_value=None, new_values=None ): + if new_values != None: + old_value = self.TKStringVar.get() + self.Values = new_values + self.TKSpinBox.configure(values=new_values) + self.TKStringVar.set(old_value) if new_value is not None: try: self.TKStringVar.set(new_value) except: pass self.DefaultValue = new_value - if new_values != None: - self.Values = new_values - self.TKSpinBox.configure(values=new_values) def SpinChangedHandler(self, event): From 40983fb873eb18fd26559d43afcdd2e091ec1f6d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 10 Sep 2018 20:24:04 -0400 Subject: [PATCH 2/2] Updated Menu demo --- Demo_Menus.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Demo_Menus.py b/Demo_Menus.py index 1d7625f9..7b3c884f 100644 --- a/Demo_Menus.py +++ b/Demo_Menus.py @@ -6,16 +6,27 @@ import PySimpleGUI as sg Check out the variable menu_def for a hint on how to define menus """ +def SecondForm(): + + layout = [[sg.Text('The second form is small \nHere to show that opening a window using a window works')], + [sg.OK()]] + + form = sg.FlexForm('Second Form') + b, v = form.LayoutAndRead(layout) + + def TestMenus(): import PySimpleGUI as sg sg.ChangeLookAndFeel('LightGreen') sg.SetOptions(element_padding=(0, 0)) - menu_def = [['File', ['Open', 'Save',]], + # ------ Menu Definition ------ # + menu_def = [['File', ['Open', 'Save', 'Properties']], ['Edit', ['Paste', ['Special', 'Normal',], 'Undo'],], ['Help', 'About...'],] + # ------ GUI Defintion ------ # layout = [ [sg.Menu(menu_def)], [sg.Output(size=(60,20))] @@ -24,19 +35,22 @@ def TestMenus(): form = sg.FlexForm("Windows-like program", default_element_size=(12, 1), auto_size_text=False, auto_size_buttons=False, default_button_element_size=(12, 1)) form.Layout(layout) - form.ReadNonBlocking() # so the print message will show up... yes, a kludge - print('Give those menus a try!') + # ------ Loop & Process button menu choices ------ # while True: button, values = form.Read() if button is None or button == 'Exit': return print('Button = ', button) + # ------ Process menu choices ------ # if button == 'About...': sg.Popup('About this program','Version 1.0', 'PySimpleGUI rocks...') elif button == 'Open': filename = sg.PopupGetFile('file to open', no_window=True) print(filename) + elif button == 'Properties': + SecondForm() + TestMenus() \ No newline at end of file