-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
81 lines (59 loc) · 2.57 KB
/
main.py
File metadata and controls
81 lines (59 loc) · 2.57 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import webbrowser
from kivymd.app import MDApp
from kivymd.uix.transition import MDSharedAxisTransition as SAT
from kivymd.utils.set_bars_colors import set_bars_colors
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.properties import NumericProperty
import registers
from View.components.LazyManager import LazyManager
from View.components.LoadingLayout import LoadingLayout
from View.screens import screens
def set_softinput(*args) -> None:
Window.keyboard_anim_args = {"d": 0.2, "t": "in_out_expo"}
Window.softinput_mode = "below_target"
Window.on_restore(Clock.schedule_once(set_softinput, 0.1))
class UI(LazyManager):
def __init__(self, *args, **kwargs):
super(UI, self).__init__(*args, **kwargs)
self.transition = SAT()
self.loading_layout = LoadingLayout()
self.raw_views = screens
class KvDeveloper(MDApp):
# timeout to switch the screen after for demonstration.
switch_screen_timeout = NumericProperty(0)
def __init__(self, *args, **kwargs):
super(KvDeveloper, self).__init__(*args, **kwargs)
self.theme_cls.primary_palette = "Midnightblue"
self.manager_screens = UI()
def build(self) -> UI:
self.manager_screens.switch("home screen") # switch to HomeScreenView on startup.
self.apply_styles()
return self.manager_screens
# def generate_application_screens(self) -> None:
# # adds different screen widgets to the screen manager
# import View.screens
# screens = View.screens.screens
# for i, name_screen in enumerate(screens.keys()):
# view = screens[name_screen]["object"]()
# view.manager_screens = self.manager_screens
# view.name = name_screen
# self.manager_screens.add_widget(view)
def apply_styles(self, style: str = "Light") -> None:
self.theme_cls.theme_style = style
if style == "Light":
style = "Dark"
self.set_bars_colors(style)
def set_bars_colors(self, style: str = "Light") -> None:
set_bars_colors(
self.theme_cls.primaryColor, # status bar color
self.theme_cls.primaryColor, # navigation bar color
style, # icons color of status bar
)
def referrer(self, destination: str = None) -> None:
if self.manager_screens.current != destination:
self.manager_screens.switch(destination, timeout=self.switch_screen_timeout)
def web_open(self, url: str) -> None:
webbrowser.open_new_tab(url)
if __name__ == "__main__":
KvDeveloper().run()