Select your language

This simple framework uses the Kivy Screen Managers to create the navigation within the visualization. You can choose between various transitions between the Screens to support the navigation.

The screnmansger will be defined in a python and a kv file. The example below shows the principle and can be extended to your needs.

Python

Mainly the .py file holds functions to navigate between the screens. The identification is done by the name. In my case scrn1, scrn2.

This name is also found in thy .kv file.

# -*- coding: utf-8 -*-

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen

class MyScreens(ScreenManager):
    '''
    The ScreenManager MyScreens takes care of changing between the available screens
    The functions goto_screen_1 .... can be called by all elements on the screens
    '''
    def __init__(self, **kwargs):
        '''__init__() can perform actions on instantioation. None so far'''
        super(MyScreens, self).__init__(**kwargs)

    def goto_scrn1(self):
        '''Switches to screen 1'''
        self.current='scrn1'

    def goto_scrn2(self):
        '''switches to screen 2'''
        self.current='scrn2'

        
class Scrn1(Screen):
    pass

class Scrn2(Screen):
    pass

class MyVisuApp(App):
    def build(self):
        return MyScreens()

if __name__ == '__main__':
    MyVisuApp().run()

 

KV

<MyScreens>:
    Scrn1:
    Scrn2:
        
<Scrn1>:
    name: 'scrn1'
    GridLayout:
        cols: 3
        size_hint: 1, .8
        pos_hint: {'top':.9, 'left':1}
        Button:
            id: bnt1
            text: 'Wohnzimmer'
            font_size: 35
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.goto_scrn2()
        Button:
            id: btn2
            text: 'Vorhersage'
            font_size: 35
            on_press:
                root.manager.transition.direction = 'left'
                root.manager.goto_scrn3()
        Button:
            id: btn3
            text: 'Einstellungen'
            font_size: 35
            on_press: app.open_settings()
    Button:
        id: btn4
        text: 'Beenden'
        on_press: App.get_running_app().stop()
        size_hint: .1, .1
        pos_hint: {'top':1, 'left':1}
    Label:
        id: lbl1
        text: 'Hauptmenu'
        size_hint: .8, .1
        pos_hint: {'top':1, 'center_x':.5}
    Label:
        id: lbl2
        text: 'lbl2'
        size_hint: 1, .1
        pos_hint: {'bottom':1, 'center_x':.5}

#Screen 2 displays the temperature and humidity
<Scrn2>:
    name: 'scrn2'
    Button:
        id: back
        text: 'Hauptmenu'
        on_press:
            root.manager.transition.direction = 'right'
            root.manager.goto_scrn1()
        size_hint: .1, .1
        pos_hint: {'top':1, 'left':1}
    Button:
        id: btn1
        text: 'Diagramm'
        on_press:
            root.manager.transition.direction = 'right'
            root.manager.goto_scrn4()
        size_hint: .1, .1
        pos_hint: {'top':1, 'right':1}
    Label:
        id: lbl1
        text: 'Wohnzimmer'
        size_hint: .8, .1
        pos_hint: {'top':1, 'center_x':.5}
    Label:
        id: lbl2
        text: 'lbl2'
        size_hint: 1, .1
        pos_hint: {'bottom':1, 'center_x':.5}

The result looks something like the screenshots below, depending on the amount of screens you added. They will be filled with actual working widgets as needed later on.