From d7a4f5c5b8afd68c38da051b28689ac0fcf2c6a8 Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Mon, 25 Oct 2010 03:16:27 -0500 Subject: [PATCH] Fixed Windows close-tab bug (I think); refactored This commit SHOULD fix Ctrl-W/menu-bar closing on Windows; also, the code was refactored into a new multiSwitch method --- gui/mainFrame.py | 7 ++----- gui/multiSwitch.py | 8 ++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index c98218c43..68bc21020 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -114,12 +114,9 @@ class MainFrame(wx.Frame): tab, _ = self.notebookBrowsers.HitTest(event.Position) if tab != -1: self.notebookBrowsers.SetSelection(tab) - + def CloseCurrentFit(self, evt): - self.fitMultiSwitch.removeTab(self.fitMultiSwitch.GetSelection()) - #Deleting a tab might have put us on the "+" tab, make sure we don't stay there - if self.fitMultiSwitch.GetSelection() == self.fitMultiSwitch.GetPageCount() - 1: - self.fitMultiSwitch.SetSelection(self.fitMultiSwitch.GetPageCount() - 2) + self.fitMultiSwitch.removeCurrentTab() def ExitApp(self, evt): try: diff --git a/gui/multiSwitch.py b/gui/multiSwitch.py index a38afa8b9..54220d752 100644 --- a/gui/multiSwitch.py +++ b/gui/multiSwitch.py @@ -104,6 +104,14 @@ class MultiSwitch(wx.Notebook): self.removal = False + def removeCurrentTab(self): + self.removal = True + self.removeTab(self.GetSelection()) + #Deleting a tab might have put us on the "+" tab, make sure we don't stay there + if self.GetSelection() == self.GetPageCount() - 1: + self.SetSelection(self.GetPageCount() - 2) + self.removal = False + def checkAdd(self, event): if event.Selection == self.GetPageCount() - 1: if "__WXMSW__" not in wx.PlatformInfo: