I'm bit confused why this is not working. Simple version of what I have is bellow. What I need is to screen manager start the main screen, on load it will start thread and do it thing updating the main screen labels... but also it should start clock. Lets say after 10 sec switch to second screen.. Until here it works... but the same needs to happen on the second screen, start clock and after 10 sec go back to main screen, this will happen in background but visually the screen will not change. Not sure what is going on :(
osd.py:
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.clock import Clock, mainthread
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
import MySQLdb
import threading
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
class PauseScreen(Screen):
def on_enter(self):
print('enter')
Clock.schedule_once(self.switch_back, 5)
def switch_back(self, *args):
print('back')
self.clear_widgets()
self.parent.current = "OSD_screen"
class MainScreen(Screen):
def on_enter(self):
print('start threading')
#Clock.schedule_once(self.update_thread, 0.1)
Clock.schedule_once(self.switch, 5)
# def __init__(self, **kwargs):
# super(MainScreen, self).__init__(**kwargs)
#Clock.schedule_interval(self.update_thread, 20)
# Clock.schedule_once(self.update_thread, 0.1)
# Clock.schedule_once(self.switch, 5)
def switch(self, *args):
self.parent.current = "pause"
class ScreenManagement(ScreenManager):
stop = threading.Event()
pass
presentation = Builder.load_file("osd.kv")
class osdApp(App):
def on_stop(self):
self.root.stop.set()
def build(self):
return presentation
if __name__ == '__main__':
osdApp().run()
osd.kv
ScreenManagement:
id: screen_manager
MainScreen:
id: main_screen
name: 'OSD_screen'
manager: 'screen_manager'
PauseScreen:
id: pause_screen
name: 'pause'
manager: 'screen_manager'
<MainScreen>:
BoxLayout:
orientation: 'vertical'
Label:
text_size: self.size
text: 'MainScreen'
font_size: 50
bold: True
halign: 'center'
valign: 'top'
size_hint: 1, .3
<PauseScreen>:
BoxLayout:
orientation: 'vertical'
Label:
text: 'Pause Screen'
font_size: 25