| 24 | _t = wx.GetTranslation |
| 25 | |
| 26 | class MultiSwitch(ChromeNotebook): |
| 27 | def __init__(self, parent): |
| 28 | ChromeNotebook.__init__(self, parent, can_add=True, tabWidthMode=1) |
| 29 | # self.AddPage() # now handled by mainFrame |
| 30 | self.handlers = handlers = [] |
| 31 | for type in TabSpawner.tabTypes: |
| 32 | handlers.append(type(self)) |
| 33 | |
| 34 | def handleDrag(self, type, info): |
| 35 | for handler in self.handlers: |
| 36 | h = getattr(handler, "handleDrag", None) |
| 37 | if h: |
| 38 | h(type, info) |
| 39 | |
| 40 | def AddPage(self, tabWnd=None, tabTitle=None, tabImage=None): |
| 41 | tabTitle = tabTitle or _t("Empty Tab") |
| 42 | if tabWnd is None: |
| 43 | tabWnd = gui.builtinViews.emptyView.BlankPage(self) |
| 44 | tabWnd.handleDrag = lambda type, info: self.handleDrag(type, info) |
| 45 | |
| 46 | ChromeNotebook.AddPage(self, tabWnd, tabTitle, tabImage, True) |
| 47 | |
| 48 | def DeletePage(self, n, *args, **kwargs): |
| 49 | ChromeNotebook.DeletePage(self, n, *args, **kwargs) |
| 50 | if self.GetPageCount() == 0: |
| 51 | self.AddPage() |
| 52 | |
| 53 | class TabSpawner: |
| 54 | tabTypes = [] |