-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (37 loc) · 1.34 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'''
This script is the main script which is run when the app is opened
It starts the main thread as well as setup the app for running
'''
from kivy.app import App
from pages import Home, Page3, StageSel, ViewLog, SetPage
from kivy.uix.screenmanager import ScreenManager,NoTransition
from kivy.core.window import Window
from kivy.clock import Clock
from globals import update_clock
class MainApp(App):
'''Class for the main app'''
sm = ScreenManager(transition=NoTransition())
use_kivy_settings = False
def build(self):
home = Home(name="Home")
self.loc_but = home.loc_but
self.sm.add_widget(home)
self.sm.add_widget(Page3(name="Page3"))
self.sm.add_widget(StageSel(name="StageSel"))
self.sm.add_widget(ViewLog(name="Log"))
self.sm.add_widget(SetPage(name='Settings'))
self.rv = self.sm.get_screen('Page3').rv
Clock.schedule_interval(update_clock, 0.1)
win = Window
win.bind(on_keyboard=self.my_key_handler)
return self.sm
def my_key_handler(self, window, keycode1, keycode2, text, modifiers):
if keycode1 in [27, 1001]:
if self.sm.current == 'Home':
return False
else:
self.sm.current = 'Home'
return True
return False
if __name__=="__main__":
MainApp().run()