def _ClosePageNum(self, idx, deletepg=True): """Close the given page @param idx: int @keyword deletepg: bool (Internal Use Only!) @return bool: was page deleted? """ try: page = self.GetPage(idx) result = page.CanCloseTab() # TODO: this makes very little sense, why did this deletepg # value get added, this function is useless when it # is not true... if result and deletepg: evt = aui.AuiNotebookEvent( aui.wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, SIMULATED_EVT_ID) evt.SetSelection(idx) self.OnPageClosing(evt) self.TopLevelParent.Freeze() # prevent flashing on OSX self.DeletePage(idx) self.TopLevelParent.Thaw() evt = aui.AuiNotebookEvent( aui.wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, SIMULATED_EVT_ID) evt.SetSelection(idx) self.OnPageClosed(evt) except Exception: # TODO: workaround for crash in base on destruction pass return result
def _ClosePageNum(self, idx, deletepg=True): """Close the given page @param idx: int @keyword deletepg: bool (Internal Use Only!) @return bool: was page deleted? """ frame = self.GetTopLevelParent() frame.Freeze() try: page = self.GetPage(idx) result = page.CanCloseTab() if result and deletepg: evt = aui.AuiNotebookEvent(aui.wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, SIMULATED_EVT_ID) self.OnPageClosing(evt) self.DeletePage(idx) evt = aui.AuiNotebookEvent(aui.wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, SIMULATED_EVT_ID) evt.SetSelection(idx) self.OnPageClosed(evt) finally: frame.Thaw() return result