def switch_screen(self, style = 'slide', screen_to_switch = None, clear = False, prompt = None, *args):
'''
switch screen with given transition
if screen is not defined it will switch to the last remembered screen (screen variable: last_screen)
if clear is true it will overwrite screen variable: last_screen
'''
# #from kivy.uix.screenmanager import ScreenManager, FadeTransition#, SlideTransition, SwapTransition, WipeTransition, FallOutTransition, RiseInTransition
# #from kivy.garden.moretransitions import BlurTransition#,PixelTransition,RippleTransition,RVBTransition
# #app = App.get_running_app()
# #self.last_screen = app.root.current
# #SlideTransition, SwapTransition, WipeTransition, FallOutTransition, RiseInTransition, FadeTransition
# #PixelTransition,RippleTransition,BlurTransition,RVBTransition
# transitions = { #'rise' : RiseInTransition(),
# #'fall' : FallOutTransition(),
# 'slide' : SlideTransition(),
# #'blur' : BlurTransition(),
# #'fade' : FadeTransition() }
# #transition = SlideTransition(direction="left")
# self.transition = transitions[style] # setting transition style
self.transition.direction = 'down'
self.transition.duration = self.duration
cached_screen = self.current # caching current screen to write it later as last_screen
if screen_to_switch:
''' if there is target screen defined then switch to it '''
self.current = screen_to_switch
if prompt:
self.get_screen(self.current).set_prompt(prompt)
else:
''' else switch to last+screen '''
self.current = self.get_screen(self.current).last_screen
if self.get_screen(self.current).last_screen is None:
''' if current (newly switched) screen has no last_screen defined, then define it now from cached_screen '''
self.get_screen(self.current).last_screen = cached_screen
elif clear == True:
''' if clear is forced, then overwrite current last_screen with cached screen anyway '''
self.get_screen(self.current).last_screen = cached_screen
评论列表
文章目录