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

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

项目: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
项目:webkivy    作者:miohtama    | 项目源码 | 文件源码
def run_script(self):
        self.write_settings()

        url = self.root.get_screen("landing").ids.url.text

        try:

            if not self.loader.has_original_state():
                self.loader.record_original_state()

            self.loader.reset()

            result = self.loader.load_and_run(url)

            if not isinstance(result, Screen):
                raise RuntimeError("Entry point did not return kivy.uix.screenmanager.Screen")

            self.root.switch_to(result)

            # TODO: Loader keeps leaving tmp folders around, make sure they are cleaned up

        except Exception as e:
            show_exception(e)
项目: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
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def generate_connecting_screen(self, obj, *args):
        # remove keyboard from screen
        self.wifi_status = 'nothing'
        Window.release_all_keyboards()

        # wifi credentials
        if obj.id == 'encrypted':
            psk = obj.ids.password.text
        else:
            psk = ''
        ssid = obj.ssid
        self.wifi_data = {'ssid': ssid, 'psk': psk, 'force': True}

        # layout for connecting screen
        s = Screen(name=self.name+'[2]')
        c = WifiConnecting(ssid=ssid)
        s.add_widget(c)
        self.rsm.add_widget(s)
        self.rsm.current = s.name
        self.temp_screen = s

        thread.start_new_thread(self.connectWifi_thread, ())
        Clock.schedule_interval(self.connectWifi_callback, 1)
        #self.generate_confirmation_screen(s)
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def generate_connecting_screen(self, obj, *args):
        # remove keyboard from screen
        self.wifi_status = 'nothing'
        Window.release_all_keyboards()

        # wifi credentials
        if obj.id == 'encrypted':
            psk = obj.ids.password.text
        else:
            psk = ''
        ssid = obj.ssid
        self.wifi_data = {'ssid': ssid, 'psk': psk, 'force': True}

        # layout for connecting screen
        s = Screen(name=self.name+'[2]')
        c = WifiConnecting(ssid=ssid)
        s.add_widget(c)
        self.rsm.add_widget(s)
        self.rsm.current = s.name
        self.temp_screen = s

        thread.start_new_thread(self.connectWifi_thread, ())
        Clock.schedule_interval(self.connectWifi_callback, 1)
        #self.generate_confirmation_screen(s)
项目:KivyCleanMasterDemo    作者:HeaTTheatR    | 项目源码 | 文件源码
def show_new_screen(self, instance_new_screen, string_new_name_screen):
        """????????????? ????? ?????."""

        # ???? ???????? ??????? ???? ? ??? ?? ?????, ????????, About ? About.
        name_current_screen = self.start_screen.screen_manager.current
        if name_current_screen == string_new_name_screen:
            return

        # ??????? ????? ????? (Activity).
        screen = Screen(name=string_new_name_screen)
        screen.add_widget(instance_new_screen)

        # ????????? Activity ? ???????? ????????;
        # ????????????? ???????? ????? ??????;
        # ??????? Activity ?? ?????;
        # ????????????? ??? Activity ? ActionBar;
        # ?????? ?????? action_previous ? ????? ???? ActionBar.
        self.start_screen.screen_manager.add_widget(screen)
        self.start_screen.screen_manager.transition = FadeTransition()
        self.start_screen.screen_manager.current = string_new_name_screen
        self.start_screen.action_previous.title = string_new_name_screen
        self.start_screen.action_previous.app_icon = \
            "Data/Images/arrow_left.png"
项目:PyWallet    作者:AndreMiras    | 项目源码 | 文件源码
def screen_manager_current(self, current, direction=None, history=True):
        screens = {
            'overview': OverviewScreen,
            'switch_account': SwitchAccountScreen,
            'manage_keystores': ManageKeystoreScreen,
            'flashqrcode': FlashQrCodeScreen,
            'about': AboutScreen,
        }
        screen_manager = self.screen_manager
        # creates the Screen object if it doesn't exist
        if not screen_manager.has_screen(current):
            screen = screens[current](name=current)
            screen_manager.add_widget(screen)
        if direction is not None:
            screen_manager.transition.direction = direction
        screen_manager.current = current
        if history:
            # do not update history if it's the same screen because we do not
            # want the go back button to behave like it was doing nothing
            if not self.screen_history or self.screen_history[-1] != current:
                self.screen_history.append(current)
        # in this case let's reset since the overview is the root screen
        # because we never want the back button to bring us from overview
        # to another screen
        if current == 'overview':
            self.screen_history = []
项目: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
项目:KivyMdDemo    作者:captainbupt    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(MyScreenManager, self).__init__(**kwargs)
        self.add_widget(MyScreen(name='Screen 1'))
        self.current = 'Screen 1'
项目:thermostat_ita    作者:jpnos26    | 项目源码 | 文件源码
def light_off( dt ):
    with thermostatLock:
        GPIO.output( lightPin, GPIO.LOW )
        log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCREEN, MSG_SUBTYPE_TEXT, "Screen Off" )
项目:MazeGenerator    作者:MazeFX    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Screen, self).__init__(**kwargs)
        Clock.schedule_once(self.callback)
        self.corridor_set = CORRIDOR
        self.wall_set = WALL
        self.corner_set = CORNER
        self.corner_size_set = CORNERSIZE
        self.dot_set = DIAMDOT
        self.animation_set = ANIMSPEED
项目:MazeGenerator    作者:MazeFX    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Screen, self).__init__(**kwargs)
        self.root = None
        self.started = False
        self.createmaze()
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def build(self):
        # Instantiate Screen Manager and add a child widget-- the Main Screen
        # Root widget is RoboScreenManager
        sm = RoboScreenManager(transition=NoTransition())
        sm.add_widget(MainScreen(name='main'))
        return sm
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def ap_mode_2_4(self, **kwargs):
        c = Screen(name=self.name + '[2]')
        s = AP_Mode_2_4(self)
        c.add_widget(s)

        self.sm.add_widget(c)
        self.sm.current = c.name

        #start the hotspot
        self.generate_ap_confirmation_screen()

        Clock.schedule_interval(self.ap_mode_2_4_callback, .5)
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def ap_mode_failure(self, **kwargs):
        c = Screen(name=self.name+'[3]')
        s = AP_Mode_Failure(self)
        c.add_widget(s)

        self.sm.add_widget(c)
        self.sm.current = c.name
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def ap_mode_success(self, **kwargs):
        c = Screen(name=self.name+'[4]')
        s = AP_Mode_Success(self)
        c.add_widget(s)


        self.sm.add_widget(c)
        self.sm.current = c.name

        self.save_connection_info()
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def _generate_failure_screen(self, *args):
        s = Screen(name=self.name+'[3]')
        c = WifiFailure(self._retry_config)
        s.add_widget(c)

        self.rsm.add_widget(s)
        self.rsm.current = s.name
项目:high-quality-chat    作者:b6938236    | 项目源码 | 文件源码
def build(self):
        # Kivy is stubborn and overrides self.config with a built-in ConfigParser
        self.config = hqc_config.get_instance(file="conn.conf")
        # Give the web socket a reference to the app
        gui = Builder.load_file("HQC.kv")
        self.root = gui
        # Link application to Screen Manager
        self.root.app = self
        return gui
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def build(self):
        # Instantiate Screen Manager and add a child widget-- the Main Screen
        # Root widget is RoboScreenManager
        sm = RoboScreenManager(transition=NoTransition())
        sm.add_widget(MainScreen(name='main'))
        return sm
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def ap_mode_2_4(self, **kwargs):
        c = Screen(name=self.name + '[2]')
        s = AP_Mode_2_4(self)
        c.add_widget(s)

        self.sm.add_widget(c)
        self.sm.current = c.name

        #start the hotspot
        self.generate_ap_confirmation_screen()

        Clock.schedule_interval(self.ap_mode_2_4_callback, .5)
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def ap_mode_failure(self, **kwargs):
        c = Screen(name=self.name+'[3]')
        s = AP_Mode_Failure(self)
        c.add_widget(s)

        self.sm.add_widget(c)
        self.sm.current = c.name
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def ap_mode_success(self, **kwargs):
        c = Screen(name=self.name+'[4]')
        s = AP_Mode_Success(self)
        c.add_widget(s)


        self.sm.add_widget(c)
        self.sm.current = c.name

        self.save_connection_info()
项目:RoboLCD    作者:victorevector    | 项目源码 | 文件源码
def _generate_failure_screen(self, *args):
        s = Screen(name=self.name+'[3]')
        c = WifiFailure(self._retry_config)
        s.add_widget(c)

        self.rsm.add_widget(s)
        self.rsm.current = s.name
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def sethotkey1_ScreenToggle(obj):
        global hotkey1string
        hotkey1string = "Screen Toggle"
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def sethotkey2_ScreenToggle(obj):
        global hotkey2string
        hotkey2string = "Screen Toggle"
项目:AppLogin    作者:KugiHaito    | 项目源码 | 文件源码
def addslashes(s):
    d = {'"':'\\"', "'":"\\'", "\0":"\\\0", "\\":"\\\\"}
    return ''.join(d.get(c, c) for c in s)

# Screen's
项目:DemoKivyContacts    作者:HeaTTheatR    | 项目源码 | 文件源码
def add_screens(self, name_screen, screen_manager, new_screen):
        screen = Screen(name=name_screen)
        screen.add_widget(new_screen)
        screen_manager.add_widget(screen)
        screen_manager.current = name_screen
项目:osava    作者:osava-nsit    | 项目源码 | 文件源码
def display_error(grid, error, box_height='400dp'):
    error_box = BoxLayout(orientation='horizontal', size_hint_y=None, height=box_height)
    error_label = Label(text="Bad Input:\n" + error, size_hint_x=None, width=Window.width, valign='top', halign='center')
    # error_label.text_size = error_label.size
    error_box.add_widget(error_label)
    grid.add_widget(error_box)
    return error_box

# Main Menu Screen with options to choose an OS Algorithm
项目:osava    作者:osava-nsit    | 项目源码 | 文件源码
def toggle_about_text(self, *args):
        if self.about_visible:
            self.about_label.text = ""
            self.about_visible = False
        else:
            self.about_label.text = 'Developers: Udit Arora, Namrata Mukhija, Priyanka, Rohit Takhar\nAdvisor: Dr. Pinaki Chakraborty\n'
            self.about_visible = True

# Input Screen for CPU Scheduling Algorithms with partial scrolling
项目:osava    作者:osava-nsit    | 项目源码 | 文件源码
def switch_to_main_menu(self, *args):
        self.manager.transition.direction = 'right'
        self.manager.current = 'menu'


# Output Screen for CPU Scheduling algorithms
项目:osava    作者:osava-nsit    | 项目源码 | 文件源码
def switch_to_da_form(self, *args):
        self.manager.transition.direction = 'right'
        self.manager.current = 'da_form'


# Input Screen for Deadlock Detection algorithm
项目:osava    作者:osava-nsit    | 项目源码 | 文件源码
def switch_to_page_form(self, *args):
        self.manager.transition.direction = 'right'
        self.manager.current = 'page_form'


# Input Screen for Disk Scheduling Algorithms
项目:SuperOcto    作者:mcecchi    | 项目源码 | 文件源码
def save(self, usb = False, *args,**kwargs):
        if self.meta != None:
            self.save_meta()
        save_dir = roboprinter.robo_screen()
        Logger.info(save_dir)
        save_dir = save_dir.replace("ROBOSAVE", "")
        Logger.info(save_dir)

        filename = os.path.basename(self.temp_file_path)

        if save_dir == 'local':
            save_dir = FILES_DIR + "/"+ filename
            final_dir = save_dir
            counter = 0
            #don't overwrite an already saved file
            while os.path.isfile(final_dir):
                counter += 1
                final_dir = save_dir.replace(".gcode", "_" + str(counter) + ".gcode")

            short_dir = 'local/'
        else:
            short_dir = save_dir  + "/"
            save_dir = FILES_DIR + "/" + save_dir + "/"+ filename
            final_dir = save_dir
            counter = 0
            #dont overwrite an already saved file
            while os.path.isfile(final_dir):
                counter += 1
                final_dir = save_dir.replace(".gcode", "_" + str(counter) + ".gcode")



        if os.path.isfile(self.temp_file_path):
            #copy the file
            shutil.copyfile(self.temp_file_path, final_dir)
            #remove the temporary file if it is not from a USB drive
            if not usb:
                os.remove(self.temp_file_path)

            fit_filename = filename.replace(".gcode", "_" + str(counter))


            if len(fit_filename) > 24:
                fit_filename = "..." + fit_filename[len(fit_filename) - 24:]

            layout = Confirmation_Screen(roboprinter.lang.pack['Files']['Save_File']['Sub_Title'],  fit_filename + roboprinter.lang.pack['Files']['Save_File']['Body'], "Icons/Slicer wizard icons/check_icon.png", roboprinter.robosm.go_back_to_main)            
            sc = Screen(name = 'confirmation')
            sc.add_widget(layout)
            roboprinter.robosm.add_widget(sc)
            roboprinter.robosm.current = sc.name

        Logger.info('File Saved/Removed')
        #add a 2 second delay for updating files
        Clock.schedule_once(self.update_files, 2)
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def HotKey1(channel):
    global hotkey1string
    global screenon
    global windowuptime
    global windowdowntime
    global WINDOWSUPON
    global WINDOWSDOWNON
    if hotkey1string == "Seek Up":
        Clock.schedule_once(seekup_callback)
        Clock.schedule_once(seekup_callback,.1)
    if hotkey1string == "Seek Down":
        Clock.schedule_once(seekdown_callback)
        Clock.schedule_once(seekdown_callback,.1)
    if hotkey1string == "Garage":
        Clock.schedule_once(garage_callback)
        Clock.schedule_once(garage_callback,.1)
    if hotkey1string == "Radar":
        Clock.schedule_once(radar_callback)
    if hotkey1string == "Cup Lights":
        Clock.schedule_once(leds_callback)

    if hotkey1string == "Windows Up":
        if WINDOWSDOWNON == 0: #only works when windows down isnt running
            Clock.schedule_once(windowsup_callback)
            Clock.schedule_once(windowsupOFF_callback, windowuptime)
            return
        if WINDOWSUPON == 1:
            Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows

    if hotkey1string == "Windows Down":
        if WINDOWSUPON == 0: #only works when windows up isnt running
            Clock.schedule_once(windowsdown_callback)
            Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
            return
        if WINDOWSDOWNON == 1:
            Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows

    if hotkey1string == "Screen Toggle":
        if screenon == 1:
            os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
            screenon = 0
            return
        if screenon == 0:
            os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
            screenon = 1
            return
    if hotkey1string == "None":
        return
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def HotKey2(channel):
    global hotkey2string
    global screenon
    global windowuptime
    global windowdowntime
    global WINDOWSUPON
    global WINDOWSDOWNON
    if hotkey2string == "Seek Up":
        Clock.schedule_once(seekup_callback)
        Clock.schedule_once(seekup_callback,.1)
    if hotkey2string == "Seek Down":
        Clock.schedule_once(seekdown_callback)
        Clock.schedule_once(seekdown_callback,.1)
    if hotkey2string == "Garage":
        Clock.schedule_once(garage_callback)
        Clock.schedule_once(garage_callback,.1)
    if hotkey2string == "Radar":
        Clock.schedule_once(radar_callback)
    if hotkey2string == "Cup Lights":
        Clock.schedule_once(leds_callback)

    if hotkey2string == "Windows Up":
        if WINDOWSDOWNON == 0: #only works when windows down isnt running
            Clock.schedule_once(windowsup_callback)
            Clock.schedule_once(windowsupOFF_callback, windowuptime)
            return
        if WINDOWSUPON == 1:
            Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows

    if hotkey2string == "Windows Down":
        if WINDOWSUPON == 0: #only works when windows up isnt running
            Clock.schedule_once(windowsdown_callback)
            Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
            return
        if WINDOWSDOWNON == 1:
            Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows

    if hotkey2string == "Screen Toggle":
        if screenon == 1:
            os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
            screenon = 0
            return
        if screenon == 0:
            os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
            screenon = 1
            return
    if hotkey2string == "None":
        return