From b4fb2ae839b030ea34ca7cf23dc777d4b4bfbe39 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 17 Sep 2018 12:46:37 -0400 Subject: [PATCH] Button clicks return key instead of button text if key is present --- PySimpleGUI.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 1cfb8af1..a045c2cc 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -901,7 +901,10 @@ class Button(Element): def ButtonPressCallBack(self, parm): r, c = self.Position self.ParentForm.LastButtonClickedWasRealtime = True - self.ParentForm.LastButtonClicked = self.ButtonText + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = self.ButtonText # ------- Button Callback ------- # def ButtonCallBack(self): @@ -957,7 +960,10 @@ class Button(Element): # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position - self.ParentForm.LastButtonClicked = self.ButtonText + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = self.ButtonText self.ParentForm.FormRemainedOpen = False # if the form is tabbed, must collect all form's results and destroy all forms if self.ParentForm.IsTabbedForm: @@ -971,7 +977,10 @@ class Button(Element): elif self.BType == BUTTON_TYPE_READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE # first, get the results table built # modify the Results table in the parent FlexForm object - self.ParentForm.LastButtonClicked = self.ButtonText + if self.Key is not None: + self.ParentForm.LastButtonClicked = self.Key + else: + self.ParentForm.LastButtonClicked = self.ButtonText self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # this is a return type button so GET RESULTS and destroy window