def load_screen(self, screen, manager=None, store_back=True):
'''Load the provided screen:
arguments::
`screen`: is the name of the screen to be loaded
`manager`: the manager to load this screen, this defaults to
the main class.
'''
store_back = False if screen == 'StartupScreen' else store_back
manager = manager or self.root
# load screen modules dynamically
# for example load_screen('LoginScreen')
# will look for uix/screens/loginscreen
# load LoginScreen
module_path = screen.lower()
if not hasattr(self, module_path):
import imp
module = imp.load_module(screen, *imp.find_module(module_path))
screen_class = getattr(module, screen)
sc = screen_class()
sc.from_back = not store_back
setattr(self, module_path, sc)
manager.add_widget(sc)
else:
sc = getattr(self, module_path)
sc.from_back = not store_back
manager.current = screen
if store_back:
self._navigation_higherarchy.append(sc)
return getattr(self, module_path)
# Check if app is started as main and only then insitantiate the App class.
评论列表
文章目录