Python kivy.uix.screenmanager.ScreenManager() Examples

The following are 12 code examples of kivy.uix.screenmanager.ScreenManager(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module kivy.uix.screenmanager , or try the search function .
Example #1
Source File: viewer.py    From kivy-smoothie-host with GNU General Public License v3.0 5 votes vote down vote up
def build(self):
            Window.size = (1024, 768)
            self.sm = ScreenManager()
            self.sm.add_widget(StartScreen(name='start'))
            self.sm.add_widget(GcodeViewerScreen(name='gcode'))
            self.sm.add_widget(ExitScreen(name='main'))
            self.sm.current = 'gcode'

            level = LOG_LEVELS.get('debug') if len(sys.argv) > 2 else LOG_LEVELS.get('info')
            Logger.setLevel(level=level)
            # logging.getLogger().setLevel(logging.DEBUG)
            return self.sm 
Example #2
Source File: spindle_camera.py    From kivy-smoothie-host with GNU General Public License v3.0 5 votes vote down vote up
def build(self):
            # Window.size = (800, 480)
            self.sc = SpindleCamera(name='spindle camera')
            self.scr = StartScreen(name='main')
            self.sm = ScreenManager()
            self.sm.add_widget(self.scr)
            self.sm.add_widget(self.sc)
            if not self.test:
                self.sm.current = 'spindle camera'

            return self.sm 
Example #3
Source File: app.py    From segreto-3 with MIT License 5 votes vote down vote up
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' 
Example #4
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def build(self):
		screen = ScreenManager(transition=SwapTransition())
		screen.add_widget(FirstScreen())
		screen.add_widget(SecondScreen())
		screen.add_widget(ThirdScreen())
		return screen 
Example #5
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def build(self):
		screen = ScreenManager(transition=SwapTransition())
		screen.add_widget(FirstScreen())
		screen.add_widget(SecondScreen())
		screen.add_widget(ThirdScreen())
		return screen 
Example #6
Source File: filechooser.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def __init__(self, **kwargs):
        super(FileChooser, self).__init__(**kwargs)

        self.manager = ScreenManager()
        super(FileChooser, self).add_widget(self.manager)

        self.trigger_update_view = Clock.create_trigger(self.update_view)

        self.bind(view_mode=self.trigger_update_view) 
Example #7
Source File: filechooser.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def __init__(self, **kwargs):
        super(FileChooser, self).__init__(**kwargs)

        self.manager = ScreenManager()
        super(FileChooser, self).add_widget(self.manager)

        self.trigger_update_view = Clock.create_trigger(self.update_view)

        self.bind(view_mode=self.trigger_update_view) 
Example #8
Source File: test_core.py    From pypercard with MIT License 5 votes vote down vote up
def test_card_screen_empty():
    """
    Ensure a relatively empty card results in the expected Screen object and
    the passed in ScreenManager instance and data_store is set for the card.
    """
    mock_screen_manager = mock.MagicMock()
    data_store = {"foo": "bar"}
    card = Card("title")
    result = card.screen(mock_screen_manager, data_store)
    assert card.screen_manager == mock_screen_manager
    assert card.data_store == data_store
    assert isinstance(result, Screen) 
Example #9
Source File: test_core.py    From pypercard with MIT License 5 votes vote down vote up
def test_cardapp_init_no_data_store():
    """
    Ensure the CardApp instance is set up with the expected defaults.
    """
    app = CardApp()
    assert app.data_store == {}
    assert app.cards == {}
    assert isinstance(app.screen_manager, ScreenManager)
    assert app.title == "A PyperCard Application :-)" 
Example #10
Source File: test_core.py    From pypercard with MIT License 5 votes vote down vote up
def test_cardapp_init_title_datastore_and_stack():
    """
    Ensure the CardApp instance is set up with the expected user defined
    values.
    """
    stack = [Card("test")]
    app = CardApp("An App", {"foo": "bar"}, stack)
    assert app.data_store == {"foo": "bar"}
    assert app.cards == {"test": stack[0]}
    assert isinstance(app.screen_manager, ScreenManager)
    assert app.title == "An App" 
Example #11
Source File: test_core.py    From pypercard with MIT License 5 votes vote down vote up
def test_cardapp_build():
    """
    Ensure the screen_manager instance is returned to display as the
    application.
    """
    app = CardApp()
    assert isinstance(app.build(), ScreenManager) 
Example #12
Source File: core.py    From pypercard with MIT License 4 votes vote down vote up
def screen(self, screen_manager, data_store):
        """
        Return a screen instance containing all the necessary UI items that
        have been associated with the expected event handlers.

        :param kivy.uix.screenmanager.ScreenManager screen_manager: The UI
            stack of screens which controls which card is to be displayed.
        :param dict data_store: A dictionary containing application state.
        :return: A graphical representation of the card.
        """
        # References to app related objects.
        self.screen_manager = screen_manager
        self.data_store = data_store
        # The Kivy Screen instance used to draw the UI.
        screen = Screen(name=self.title)
        # Bind event handlers to life-cycle events.
        screen.bind(on_enter=self._enter)
        screen.bind(on_pre_enter=self._pre_enter)
        screen.bind(on_pre_leave=self._leave)
        # The main layout that defines how UI elements are drawn.
        self.layout = BoxLayout(orientation="vertical")
        screen.add_widget(self.layout)
        # The sound player for this card.
        self.player = None
        # Text font size for the Screen instance.
        self.font_size = "{}sp".format(self.text_size)
        if self.form:
            self._draw_form()
        elif self.text:
            self._draw_text()
        else:
            # For padding purposes.
            self.layout.add_widget(Label(text=" "))
        if self.sound:
            self.player = SoundLoader.load(self.sound)
            self.player.loop = self.sound_repeat
        if self.background:
            self.layout.bind(size=self._update_rect, pos=self._update_rect)
            with self.layout.canvas.before:
                if isinstance(self.background, tuple):
                    Color(*self.background)
                    self.rect = Rectangle(
                        size=self.layout.size, pos=self.layout.pos
                    )
                else:
                    self.rect = Rectangle(
                        source=self.background,
                        size=self.layout.size,
                        pos=self.layout.pos,
                    )
        if self.buttons:
            self._draw_buttons()
        return screen