def add_tab(self): """Adds a new tab to this TabbedPanel. The new tab will contain a TransformPanel and attach this panel as a listener to its transform property. It will be added after the current tab, and the panel will switch to that tab. This implementation has a hard-limit of 6 tabs; the implementation will show an error dialog if this method tries to exceed that number of tabs.""" if (len(self.tab_list) > 6): dialog = ErrorDialog('No more than 6 transforms allowed') dialog.size_hint = (0.7, 0.6) dialog.pos_hint = {'x': 0.15, 'y': 0.2} return pos = self.tab_list.index(self.current_tab) content = TransformPanel() content.bind(transform=self.recalculate) panel = TabbedPanelHeader(text='', content=content) panel.background_color = (0.8, 0.8, 0.5) panel.background_down = 'a5lib/uix/tab_down.png' panel.background_normal = 'a5lib/uix/tab_up.png' self.add_widget(panel) for x in range(pos): self.shuffle_tab(x, True) tab1 = self.tab_list[pos + 1] tab2 = self.tab_list[pos] tab1.state = 'normal' tab2.state = 'down' self.switch_to(self.tab_list[pos])
def add_tab(self): """Adds a new tab to this TabbedPanel. The new tab will contain a TransformPanel and attach this panel as a listener to its transform property. It will be added after the current tab, and the panel will switch to that tab. This implementation has a hard-limit of 6 tabs; the implementation will show an error dialog if this method tries to exceed that number of tabs.""" if (len(self.tab_list) > 6): dialog = ErrorDialog('No more than 6 transforms allowed') dialog.size_hint = (0.7,0.6) dialog.pos_hint = {'x':0.15,'y':0.2} return pos = self.tab_list.index(self.current_tab) content = TransformPanel() content.bind(transform=self.recalculate) panel = TabbedPanelHeader(text='',content=content) panel.background_color = (0.8,0.8,0.5) panel.background_down = 'a5lib/uix/tab_down.png' panel.background_normal = 'a5lib/uix/tab_up.png' self.add_widget(panel) for x in range(pos): self.shuffle_tab(x,True) tab1 = self.tab_list[pos+1] tab2 = self.tab_list[pos] tab1.state = 'normal' tab2.state = 'down' self.switch_to(self.tab_list[pos])