From 951f3f1a6dd3a6b82661ff1c356c13a1feaa2f86 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 13:43:58 -0400 Subject: [PATCH] New Form Function - CloseNonBlockingForm, fix for context managers Previously an exception within the "with" block was not correctly passing along exceptions. New function to help with non-blocking forms. For forms that need to be closed that haven't been closed by a button, a new function was needed. CloseNonBlockingForm is the new function. --- PySimpleGUI.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 17e039e4..d3724cd7 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -686,6 +686,10 @@ class FlexForm: self.RootNeedsDestroying = True return results + def CloseNonBlockingForm(self): + self.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + def OnClosingCallback(self): return @@ -694,7 +698,7 @@ class FlexForm: def __exit__(self, *a): self.__del__() - return self + return False def __del__(self): for row in self.Rows: