-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (38 loc) · 1.39 KB
/
Copy pathmain.py
File metadata and controls
49 lines (38 loc) · 1.39 KB
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
46
47
48
49
"""
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
"""
__version__ = "2.1"
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.uix.screenmanager import NoTransition, ScreenManager
from globals import update_clock
from pages import Home, Page3, SetPage, StageSel, ViewLog
class MainApp(App):
"""Class for the main app"""
sm = ScreenManager(transition=NoTransition())
use_kivy_settings = False
def build(self):
Clock.schedule_interval(update_clock, 0.1)
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", version=__version__))
self.rv = self.sm.get_screen("Page3").rv
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()