from kivy.app import App
from kivy.lang import Builder

# Create both screens. Please note the root.manager.current: this is how
# you can control the ScreenManager from kv. Each screen has by default a
# property manager that gives you the instance of the ScreenManager used.
kv = """
#:import os os
#:import IncrediblyCrudeClock mart_clock.IncrediblyCrudeClock
#:import MyClockWidget mart_clock2.MyClockWidget

<MenuScreen@Screen>:
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            id: button_box
            size_hint_y: 8
            Button:
                text: 'Goto HVAC Controller'
                on_press: root.manager.current = 'hvac'
            Button:
                text: 'Switch to Phone'
        IncrediblyCrudeClock:
            size_hint_y: 2
            font_size: '50sp'
    MyClockWidget:
        size_hint: None, None
        size: 200, 200
        pos_hint:{'center_x': .5, 'center_y': .5 }

        
        
        

<HvacScreen@Screen>:
    temperature: temperature
    BoxLayout:
        orientation: 'vertical'
        Slider:
            id: temperature  # added
            min: 0
            max: 16
            step: 1
            orientation: 'horizontal'
        Label:
            text: 'temperature='+str(int(temperature.value))
        Slider:
            id: power
            min: 0
            max: 6
            step: 1
            orientation: 'horizontal'
        Label:
            text: 'Power='+str(int(power.value))
    FloatLayout:
        Button:
            text: 'Back to menu'
            on_press: app.stop() 
            size_hint: .2, .1    
            pos_hint: {'x':.8, 'y':0}

ScreenManager:
    MenuScreen:
        name: 'menu'
    HvacScreen:
        name: 'hvac' 
        

"""


# on_press: root.manager.current = 'menu'
# Declare both screens
# class MenuScreen(Screen):
#     pass
#
#
# class HvacScreen(Screen):
#     pass
#
# # Create the screen manager
#
#
# sm = ScreenManager()
# sm.add_widget(MenuScreen(name='menu'))
# sm.add_widget(HvacScreen(name='hvac'))


class TestApp(App):
    def build(self):
        return Builder.load_string(kv)


if __name__ == '__main__':
    TestApp().run()
