From 3b125f76ab08aef703b1776587c0c144d4522647 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 27 Sep 2018 16:34:01 -0400 Subject: [PATCH] Change to Spin, Slider, Listbox, Combobox - if changed submitted the window, return the KEY as the button --- PySimpleGUI.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 092e6a74..5b1e8f7c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -348,7 +348,10 @@ class Element(): MyForm = self.ParentForm # first, get the results table built # modify the Results table in the parent FlexForm object - self.ParentForm.LastButtonClicked = '' + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = '' self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop @@ -356,7 +359,10 @@ class Element(): MyForm = self.ParentForm # first, get the results table built # modify the Results table in the parent FlexForm object - self.ParentForm.LastButtonClicked = '' + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = '' self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop @@ -731,7 +737,10 @@ class Spin(Element): def SpinChangedHandler(self, event): # first, get the results table built # modify the Results table in the parent FlexForm object - self.ParentForm.LastButtonClicked = '' + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = '' self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop @@ -1608,7 +1617,10 @@ class Slider(Element): def SliderChangedHandler(self, event): # first, get the results table built # modify the Results table in the parent FlexForm object - self.ParentForm.LastButtonClicked = '' + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = '' self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop