我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用kivy.uix.screenmanager.ScreenManager()。
def build(self): Window.bind(keyboard_height=self.updateHeight) if platform == 'android': return MainWidget() # the dreaded splash screen code from kivy.uix.screenmanager import NoTransition, ScreenManager, Screen from kivy.uix.image import Image sm = ScreenManager(transition=NoTransition()) splashScr = Screen(name='SplashScreen') splashScr.add_widget(Image(source='misc/splash-desktop.png')) sm.add_widget(splashScr) mainScr = Screen(name='MainScreen') mainScr.add_widget(MainWidget()) sm.add_widget(mainScr) def switchToMainScr(instance): sm.current = 'MainScreen' Clock.schedule_once(switchToMainScr, 3) return sm
def build(self): self.transition = SlideTransition(duration = 0.8) self.about_popup = AboutPopup() setPage = Set(name = "setPage") clockPage = Clock(name = "clockPage") colorPage = Color(name = "colorPage") self.setPage = setPage self.clockPage = clockPage self.colorPage = colorPage scene = ScreenManager(transition = self.transition) self.scene = scene scene.add_widget(setPage) scene.add_widget(clockPage) scene.add_widget(colorPage) scene.current = "setPage" return scene
def build(self): self.manager = ScreenManager() self.manager.transition = FadeTransition(duration=.25) self.game = Game() for screen in [TitleMenu(), NewGame(), LoadGame(), self.game]: self.manager.add_widget(screen) self.manager.current = 'TitleMenu' self.overlay = FloatLayout() self.overlay.add_widget(self.manager) return self.overlay # def on_start(self): # self.profile = cProfile.Profile() # self.profile.enable() # # def on_stop(self): # self.profile.disable() # self.profile.dump_stats('myapp.profile')
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
def build(self): defaults = { 'listening_port': bptc.port, 'push_address': bptc.ip + ':8000', 'member_id': self.network.me.formatted_name } sm = ScreenManager() sm.add_widget(MainScreen(self.network, defaults)) sm.add_widget(NewTransactionScreen(self.network)) sm.add_widget(TransactionsScreen(self.network)) sm.add_widget(MembersScreen(self.network)) PublishNameScreen(self.network) sm.add_widget(PublishNameScreen(self.network)) debug_screen = DebugScreen(self.network, defaults, self) sm.add_widget(debug_screen) # start a thread that pushes frequently self.network.start_push_thread() debug_screen.pushing = True # push to a specific network address until knowing other members if self.cl_args.bootstrap_push: ip, port = self.cl_args.bootstrap_push.split(':') thread = BootstrapPushThread(ip, port, self.network) thread.daemon = True thread.start() return sm
def build(self): self.title = 'Cloud Clipboard' auth_token = self.get_data('creds') sm = ScreenManager() if auth_token: show_cloudcb(sm, auth_token) else: show_login(sm) return sm
def __init__(self, **kwargs): super(CaltracApp, self).__init__(**kwargs) self.sm = ScreenManager() self.inp = [] self.theme_cls = ThemeManager() self.theme_cls.theme_style = 'Dark' self.theme_cls.primary_palette = 'Green' self.theme_cls.accent_palette = 'Pink' self.nav_drawer = ObjectProperty()
def build(self): self.screenManager = ScreenManager() self.screenManager.add_widget( MainScreen(name="MainScreen") ) self.screenManager.add_widget( PowerOffScreen(name="PowerOffScreen") ) return self.screenManager;
def setup_gui(self): # vytvá?í grafické rozhraní self.sm = ScreenManager(transition=SlideTransition(direction="left")) self.gameScreen = Screen(name='GameScreen') self.layout = FloatLayoutBG(size_hint=(1,1)) self.sOverlay = FloatLayout(size_hint=(1,1)) self.field = GameMatrix(self, cols=12, rows=22, size_hint=(0.75, 0.83), pos_hint={'center_x':0.5, 'center_y':0.5}, master=self.layout, spacing=1) self.id_label = Label(font_name='font/Roboto-Thin.ttf', text=u'', pos_hint={'top':1, 'right':0.125}, size_hint=(0.125,0.085), font_size='48dp') self.overlay = Overlay(self, size_hint=(.1,1), pos_hint={"right":1}) self.dock = Dock(self, size_hint=(0.75,0.0845), pos_hint={'center_x':0.5}, opacity=1) self.layout.add_widget(self.field, index=0) self.layout.add_widget(self.id_label, index=0) self.nicknameLabel = Label(font_name='font/Roboto-Regular.ttf', text=self.nickname, pos_hint={'top':1, 'center_x':0.5}, font_size='26dp', size_hint=(0.75,0.085)) self.nextPiece = NextPiece() self.layout.add_widget(self.nextPiece) self.layout.add_widget(self.nicknameLabel, index=0) self.layout.add_widget(self.dock, index=0) self.layout.add_widget(self.overlay) self.layout.add_widget(self.sOverlay) self.layout.add_widget(GestureListener(root=self, pos_hint={'x': 0})) self.chat = Notification() self.chat.unread.opacity = 0 self.layout.add_widget(self.chat) self.gameScreen.add_widget(self.layout) self.sm.add_widget(LanguageScreen(name='LanguageScreen', root=self)) self.sm.add_widget(MainMenuScreen(name='MainMenuScreen', root=self)) self.sm.add_widget(ConnectScreen(name='ConnectScreen', root=self)) self.sm.add_widget(self.gameScreen) self.sm.add_widget(PartylineScreen(name="PartylineScreen", root=self)) self.sm.add_widget(StatsScreen(name="StatsScreen", root=self)) self.sm.add_widget(SettingsScreen(name="SettingsScreen", root=self)) self.sm.add_widget(BookmarksScreen(name="BookmarksScreen", root=self)) self.sm.add_widget(TutorialMove(root=self, name="TutorialMove", directory="moving", frames=5)) self.sm.add_widget(TutorialDrop(root=self, name="TutorialDrop", directory="drop", frames=3)) self.sm.add_widget(TutorialSpecial(root=self, name="TutorialSpecial", directory="sendspecial", frames=4)) self.sm.add_widget(TutorialNavigate(root=self, name="TutorialNavigate", directory="navigation", frames=7)) self.sm.add_widget(TutorialPlayers(root=self, name="TutorialPlayers", directory="players", frames=4)) return self.sm
def build(self): sm = ScreenManager() sm.add_widget(self.reset_landing_screen()) return sm
def build(self): from kivy.uix.screenmanager import ScreenManager root = ScreenManager() #return the root widget here return root
def build(self): self.create_protocol() sm = ScreenManager(transition=SlideTransition()) sm.add_widget(MainScreen(name='controller', protocol=self.protocol, screen_manager=sm)) sm.add_widget(NodesScreen(name='nodes', screen_manager=sm)) log.msg("%s" % self.get_application_config()) return sm
def build(self): manager = ScreenManager() login_widget = Login(name='login') manager.add_widget(login_widget) login_widget.initialize() return manager
def build(self): manager = ScreenManager() manager.add_widget(Login(name='login')) manager.add_widget(Connected(name='connected')) return manager
def build(self): manager = ScreenManager() manager.add_widget(Registrar(name='registrar')) manager.add_widget(Login(name='login')) manager.add_widget(Connected(name='connected')) return manager
def build(self): manager = ScreenManager() manager.add_widget(Inicio(name='inicio')) manager.add_widget(Login(name='login')) manager.add_widget(Registrar(name='registrar')) manager.add_widget(Connected(name='connected')) return manager
def init(self): self.username = '' self.password = '' self.crypt_file_path = '' self.screenmanager = ScreenManager(transition=SwapTransition()) self.loginscreen = LoginScreen(name='screen-login') self.loginscreen.bind(on_login=self.login) self.ideascreen = IdeaScreen(name='screen-idea') self.ideascreen.bind(on_quit_app=self.quit) self.screenmanager.add_widget(self.loginscreen) self.screenmanager.add_widget(self.ideascreen) self.screenmanager.current = 'screen-login'
def init_screen(self): screenManager = ScreenManager(transition = WipeTransition()) screenManager.add_widget(MainMenuView(name = "mainmenu")) screenManager.add_widget(SinglePlayerView(name = "singleplayer-gameplay")) screenManager.add_widget(MultiplayerOptionView(name = "multiplayer-option")) screenManager.add_widget(LocalMultiplayerView(name = "localmultiplayer-gameplay")) return screenManager
def build(self): sm = ScreenManager() #screenmanager module used for changing screens sc1 = WelcomeScreen(name='screen1') sc2 = InteractionScreen(name='screen2') sc3 = AboutScreen(name='screen3') sc4 = UiowaScreen(name='screen4') sm.add_widget(sc1) #builds the app screen by screen sm.add_widget(sc2) sm.add_widget(sc3) sm.add_widget(sc4) print (sm.screen_names) return sm
def build(self): sm = ScreenManager() #screenmanager module used for changing screens sc1 = WelcomeScreen(name='screen1') sc2 = InteractionScreen(name='screen2') sc3 = AboutScreen(name='screen3') sc4 = UiowaScreen(name='screen4') sm.add_widget(sc1) #builds the app screen by screen sm.add_widget(sc2) sm.add_widget(sc3) sm.add_widget(sc4) return sm
def build(self): sm = ScreenManager() #screenmanager module used for changing screens sc1 = WelcomeScreen(name='screen1') sc2 = InteractionScreen(name='screen2') sc3 = AboutScreen(name='screen3') sc4 = UiowaScreen(name='screen4') sm.add_widget(sc1) #builds the app screen by screen sm.add_widget(sc2) sm.add_widget(sc3) sm.add_widget(sc4) return sm #