def start(self, instance_screen_manager: ScreenManager) -> NoReturn: """ Starts the transition. This is automatically called by the :class:`ScreenManager`. """ if self.is_active: raise ScreenManagerException("start() is called twice!") self.manager = instance_screen_manager self._anim = Animation(d=self.duration, s=0) self._anim.bind(on_progress=self._on_progress, on_complete=self._on_complete) if self._direction == "up": self.add_screen(self.screen_in) else: self.add_screen(self.screen_in) self.add_screen(self.screen_out) self.screen_in.transition_progress = 0.0 self.screen_in.transition_state = "in" self.screen_out.transition_progress = 0.0 self.screen_out.transition_state = "out" self.screen_in.dispatch("on_pre_enter") self.screen_out.dispatch("on_pre_leave") self.is_active = True self._anim.start(self) self.dispatch("on_progress", 0) if self._direction == "up": self.screen_in.y = 0 self.screen_in.opacity = 0
def switch_screen(self, screen_name): if screen_name in screens.keys(): screen = screens[screen_name](name=screen_name) self.screen_manager.switch_to(screen) return else: raise ScreenManagerException('Screen {} not found'.format(screen_name))
def switch_tab(self, name_tab): """Switching the tab by name.""" if not self.ids.tab_manager.has_screen(name_tab): raise ScreenManagerException(f"No Screen with name '{name_tab}'.") self.ids.tab_manager.get_screen(name_tab).dispatch("on_tab_press") count_index_screen = [ self.ids.tab_manager.screens.index(screen) for screen in self.ids.tab_manager.screens if screen.name == name_tab ][0] numbers_screens = list(range(len(self.ids.tab_manager.screens))) numbers_screens.reverse() self.ids.tab_bar.children[numbers_screens.index( count_index_screen)].dispatch("on_press")
def switch_screen(self, screen_name): if screen_name in screens.keys(): screen = screens[screen_name](name=screen_name) self.screen_manager.switch_to(screen) else: raise ScreenManagerException('Error')