0

newbie here trying to test my hand on something new.I'm trying to display slider value from one screen on another screen. The screen I want the value to be displayed in has multiple screens embedded in it. the first picture is the first screen. home screen that contains multiple screens

below is the code for this screen:

<Thermostat>:

    BoxLayout:
        orientation: 'horizontal'
        cols: 2


        Label:
            id: Thmo
            font_size: "11sp"
            text: "INSIDE: 50" 

        Label:
            text: "More Info"
            font_size: "11sp"

<Weather>:
    BoxLayout:
    orientation: 'horizontal'
    cols: 2

    Label:
        id:Temp
        text: "OUT TEMP: "+ root.checkWeather()
        font_size: "11sp"

    Label:
        id: Locale
        text: root.locale
        font_size: "11sp"

The next screen which is the command screen is here below, i want the slider value from this screen to be updated in the home screen. I have tried using a global variable called TEMP but it did not work. any help would be appreciated. command screen

below is the code for the command screen:

<Temperature>:
BoxLayout:
    cols: 3


    Label:
        text: 'THERMOSTAT'

    Slider:
        id: temp_slider
        min: 40
        max: 100
        value: 40
        step: 1
        on_value: app.TEMP = str(temp_slider.value)

    Label:
        id: value
        text: str(temp_slider.value)

    <Vent>:
        BoxLayout:
        size_hint_y: None
        height: '48dp'
        cols: 3

    Label: 
        text: 'VENT'

    Button:
        id: state
        text: 'Open'
        on_press: root.Open(state)

    Label:
        id: cmdErr

1 Answers1

0
from kivy.app import App

value = App.get_running_app().root.ids.SCREENCONTROLLER.get_screen('SCREENAMEHERE').ids.CHILDWIDGETID.

Basically, you do your usual id traveling but you start from the very top of the running app and work downwards.

'root' here is the widget that is returned in the Apps Build Method. You haven't provided that code, so I'm assuming you returned the Screen Controller.

Once you get to the screen controller, you can use its get_screen method by entering the string name you gave to the screen you want to go to, then from their you find it through ids as if you were on that screen.

AlexAndDraw
  • 620
  • 2
  • 6
  • 12