Python kivy.uix.screenmanager 模块,ScreenManager() 实例源码

我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用kivy.uix.screenmanager.ScreenManager()

项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
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
项目:Chess-Clock    作者:engSERGIU    | 项目源码 | 文件源码
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
项目:RKSV    作者:ztp-at    | 项目源码 | 文件源码
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
项目:kivy_rpg    作者:spinningD20    | 项目源码 | 文件源码
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')
项目:Kivy-Dynamic-Screens-Template    作者:suchyDev    | 项目源码 | 文件源码
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
项目:bptc_wallet    作者:ceddie    | 项目源码 | 文件源码
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
项目:cloud-clipboard    作者:krsoninikhil    | 项目源码 | 文件源码
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
项目:caltrac    作者:shiburizu    | 项目源码 | 文件源码
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()
项目:mrPortableGUI    作者:NorthernStars    | 项目源码 | 文件源码
def build(self):
        self.screenManager = ScreenManager()
        self.screenManager.add_widget( MainScreen(name="MainScreen") )
        self.screenManager.add_widget( PowerOffScreen(name="PowerOffScreen") )
        return self.screenManager;
项目:Mobile-TetriNET    作者:Smug28    | 项目源码 | 文件源码
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
项目:webkivy    作者:miohtama    | 项目源码 | 文件源码
def build(self):
        sm = ScreenManager()
        sm.add_widget(self.reset_landing_screen())
        return sm
项目:PyCon-Mobile-App    作者:pythonindia    | 项目源码 | 文件源码
def build(self):
       from kivy.uix.screenmanager import ScreenManager
       root = ScreenManager()
       #return the root widget here
       return root
项目:iotdm-pyclient    作者:peterchauyw    | 项目源码 | 文件源码
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
项目:SrsAutoLogin    作者:ebatuhankaynak    | 项目源码 | 文件源码
def build(self):
        manager = ScreenManager()
        login_widget = Login(name='login')
        manager.add_widget(login_widget)
        login_widget.initialize()
        return manager
项目:SnapchatClone    作者:FOC96    | 项目源码 | 文件源码
def build(self):
        manager = ScreenManager()

        manager.add_widget(Login(name='login'))
        manager.add_widget(Connected(name='connected'))

        return manager
项目:SnapchatClone    作者:FOC96    | 项目源码 | 文件源码
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
项目:SnapchatClone    作者:FOC96    | 项目源码 | 文件源码
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
项目:segreto-3    作者:anselm94    | 项目源码 | 文件源码
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'
项目:Tic-Tac-Toe    作者:CSaratakij    | 项目源码 | 文件源码
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
项目:GravBox    作者:GravBoxInterface    | 项目源码 | 文件源码
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
项目:GravBox    作者:GravBoxInterface    | 项目源码 | 文件源码
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
项目:GravBox    作者:GravBoxInterface    | 项目源码 | 文件源码
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

#
项目:GravBox    作者:GravBoxInterface    | 项目源码 | 文件源码
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